C++中常用宏
C++中会常使用到宏来进行条件编译,或设置变量
1、__cplusplus
:区分当前代码为 C++ 或 C
// 定义只在C++中才进行 extern "C" 的操作
#ifdef __cplusplus
extern "C" {
#endif
void fun(int a, int b);
#ifdef __cplusplus
}
#endif
2、区分操作系统:
_WIN32
: Windows操作系统,不区分32位或64位_WIN64
: 64位Windows操作系统__linux__
:Linux操作系统__unix__
:unix操作系统