c和C++混合编程时候,由于C++存在函数重载,C和C++对函数编译的结果不同(C直接引用函数名称,而C++会加上函数名称和函数参数类型)(编译机制不同),需要对C或C++中的调用函数叫上extern "C"。
一、
C++中调用C中的函数:
C头文件.h
extern func_name(type1 name1, type2 name2);
C源文件.c
def fubc_name(type1 name1, type2 name2):
run some thing
C++源文件.cpp:
extern "C"
{
#include "C头文件.h"
}
int main(){
}
二、
在cuda编程中,直接使用extern "C"对函数定义修饰,同时声明使用时候也需要加上。
参考链接:
https://www.cnblogs.com/douzujun/p/10619393.html
https://blog.csdn.net/u013616945/article/details/75330936
-- 未完待续--