评论

收藏

[C++] C++ 系统宏定义 windows mac linux android ios

编程语言 编程语言 发布于:2021-07-07 16:09 | 阅读数:498 | 评论:0

  C++ 系统宏定义
#ifdef _WIN32
   //define something for Windows (32-bit and 64-bit, this part is common)
   #ifdef _WIN64
    //define something for Windows (64-bit only)
   #else
    //define something for Windows (32-bit only)
   #endif
#elif __APPLE__
  #include "TargetConditionals.h"
  #if TARGET_IPHONE_SIMULATOR
     // iOS Simulator
  #elif TARGET_OS_IPHONE
    // iOS device
  #elif TARGET_OS_MAC
    // Other kinds of Mac OS
  #else
  #   error "Unknown Apple platform"
  #endif
#elif __ANDROID__
  // android
#elif __linux__
  // linux
#elif __unix__ // all unices not caught above
  // Unix
#elif defined(_POSIX_VERSION)
  // POSIX
#else
#   error "Unknown compiler"
#endif
  跨平台开发时需要以上宏

  
关注下面的标签,发现更多相似文章