__cplusplus与extern的作用

1、__cplusplus的作用

C+编译器会在编译C++源程序的时候自动生成一个宏:__cplusplus,可以通过这个宏来判断是C源文件还是C++源文件。
代码如下:

#include<stdio.h>

int main()
{
#ifdef  __cplusplus
    printf("This is C++ file!");   // 若果是C++源文件,则输出这句。
#else
    printf("This is C file!");   // 若果是C源文件,则输出这句
#endif
}

2、extern的作用

详情见:https://blog.csdn.net/monroed/article/details/54880944

猜你喜欢

转载自blog.csdn.net/qq_36528804/article/details/82291185