由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - Call assembly in c++ under linux
相关主题
underscore usage in C++ name一个java class downcast 的问题
大家programming时怎么命名?c++一个问题
C++ 关于 Named Ctor Idom 的小问题请教双键的动态结构用什么数据结构比较好?
help on string parse算法的课怎么这么难???
[合集] C++: Call virtual function in a constructor.matlab struct question
[C++] 这里的Name lookup具体是一个什么样的过程?问一个perl的有关hash的问题
C++一问请问大家怎样让程序难以读懂
Angular 2像Python 3一样流行不动的可能性多大?sh question: get the file name of a script when started from a dot command
相关话题的讨论汇总
话题: name话题: asm话题: __话题: c++话题: call
进入Programming版参与讨论
1 (共1页)
G***m
发帖数: 55
1
I'm writing some code which needs to call assembly function in C++ code.
it works fine under windows, however, it does not work under linux, i googled
lot, could not figure out the problem, can anybody help me out of this.
Here is the code.
// header file a.h
#define __ASM_NAME(name) "_" name
#define __ASM_TYPE(name) ".type " __ASM_NAME(#name) ",@function\n"
#define __ASM_GLOBAL_FUNC(name,code) \
__asm__( ".align 4\n\t" \
".globl " __ASM_NAME(#name) "\n\t" \
t****t
发帖数: 6806
2
Sorry I can't write chinese.
This is most probably name inconsistent problem, including c++ name mangling
and assembly naming convention.
It seems in your original "windows" program, you used __ASM_NAME to write
name, which is just put underscore before name. This is traditional and you
said it worked. I am not very sure about windows executable naming convention,
but I heard it does use this prefix underscore. Seems there's no c++ name
mangling problem here, did you put extern "C" {} around you

【在 G***m 的大作中提到】
: I'm writing some code which needs to call assembly function in C++ code.
: it works fine under windows, however, it does not work under linux, i googled
: lot, could not figure out the problem, can anybody help me out of this.
: Here is the code.
: // header file a.h
: #define __ASM_NAME(name) "_" name
: #define __ASM_TYPE(name) ".type " __ASM_NAME(#name) ",@function\n"
: #define __ASM_GLOBAL_FUNC(name,code) \
: __asm__( ".align 4\n\t" \
: ".globl " __ASM_NAME(#name) "\n\t" \

1 (共1页)
进入Programming版参与讨论
相关主题
sh question: get the file name of a script when started from a dot command[合集] C++: Call virtual function in a constructor.
请教显示object name的问题(c++)[C++] 这里的Name lookup具体是一个什么样的过程?
对STL的set比较熟悉的进来看看C++一问
问个c++语言扩展的问题 (转载)Angular 2像Python 3一样流行不动的可能性多大?
underscore usage in C++ name一个java class downcast 的问题
大家programming时怎么命名?c++一个问题
C++ 关于 Named Ctor Idom 的小问题请教双键的动态结构用什么数据结构比较好?
help on string parse算法的课怎么这么难???
相关话题的讨论汇总
话题: name话题: asm话题: __话题: c++话题: call