如下使用 __cplusplus宏的方法可以保证 一段程序既可以在C 中被编译,要可以在C++中被编译;
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#include "add.h"
#ifdef __cplusplus
}
#endif
int main()
{
int c = add(1, 2);
printf("c = %d\n", c);
return 0;
}