为什么不应该extern "C"对于需要被定义为C函数的函数来指定?将文件编译为C源代码时对编译器有什么影响? 如果在C编译器没有任何影响,我们不能只通过删除#ifdef __cplusplus检查定义如下头文件中的函数? extern "C" {
int MyFunc();
}
An answer to another question说,#ifdef是需要的,但我不明白为什么:
如果我使用铛3.8.1编译: extern "C" {
int foo(int x) { register int y = x; return y; }
}
int main() { return foo(123); }
我得到警告: a.cpp:3:18: warning: 'register' storage class specifier is deprecated and in