c c++ 混用

来源:互联网 发布:mirrorlink已认证软件 编辑:程序博客网 时间:2024/04/25 20:33

#if defined(__cplusplus)

extern "C" {

#endif

typedef struct Node { int n;}Node ;

// 在这里面写

#if defined(__cplusplus)

}

#endif

就可以c++用c了


如果 xx.c

Node g_node;


c++文件中cppsource.cc

extern Node g_node;

这样是会链接失败的~~

得 extern "C" Node g_node;

或这在头文件包起来的地方写上这个变量声明

原创粉丝点击