在c++ MinGW中包含汇编函数
include assembly function in c++ MinGW
我想在c++中包含一个汇编函数。我用谷歌发现extern int test(int,int)
在C中工作得很好,但在c++中不行。我在c++中需要做什么?我的代码:
#include <iostream>
extern int test(int,int);
int main () {
std::cout<<test(2,2); //Here I get "../main.cpp:6: undefined reference to `test'"
return 0;
}
我正在使用eclipse与MinGW。
您可以使用extern "C"
在c++中包含汇编函数。工作的例子:
#include <iostream>
extern "C" int test(int,int);
int main () {
std::cout<<test(2,2);
return 0;
}
MinGW在函数后面加了下划线,所以在汇编中必须将其命名为_test
。
相关文章:
- 为什么 memcpy() 和其他类似的函数使用汇编?
- 英特尔汇编与内部函数,AVX
- 混合 c++ 和汇编不能将多个参数从C++函数传递到程序集
- 汇编错误:调用基本型构造函数时无效的转换
- C 汇编错误:无匹配的构造函数以进行初始化
- 如何在 x86 汇编中调用函数并将参数传递给它
- 在 GDB - C++ 中反汇编重载成员函数
- 内联函数如何编译为汇编?
- C 成员函数的汇编定义在班级主体之外
- 指示汇编时间叫什么构造函数
- 传递variadic arg to模板函数时的汇编误差
- 汇编函数调用是否会导致所有寄存器被推送到堆栈中
- 将C++内联汇编函数转换为delphi内联汇编函数
- C++向内联汇编函数传递参数
- 反汇编函数参数(无符号__int8)大海捞针[19] << 8)
- AVR-GCC不链接c++与汇编函数
- 从c++调用汇编函数
- 在c++ MinGW中包含汇编函数
- 如何从C++动态调用汇编函数
- visual MSVC汇编函数参数