C++中常用宏

C++中会常使用到宏来进行条件编译,或设置变量

1、__cplusplus:区分当前代码为 C++ 或 C

// 定义只在C++中才进行 extern "C" 的操作
#ifdef __cplusplus
extern "C" {
#endif

void fun(int a, int b);

#ifdef __cplusplus
}
#endif

2、区分操作系统:

  1. _WIN32: Windows操作系统,不区分32位或64位
  2. _WIN64: 64位Windows操作系统
  3. __linux__:Linux操作系统
  4. __unix__:unix操作系统
posted @ 2024-08-28 14:09  Jeffxue  阅读(8)  评论(0编辑  收藏  举报