定义系统平台编译器位数的宏版本 & Windows 及 Visual Studio 发行时间

// 参考:
// "编译器中和64位编程有关的预定义宏"
// https://blog.youkuaiyun.com/liangbch/article/details/36020391
// 《Calling conventions for different C++ compilers and operating systems》,
// Last updated 2012-02-29,By Agner Fog. Copenhagen University College.
// # 查看内置宏:
//   gcc -dM -E - < /dev/null
// # 查看系统位数
//   getconf LONG_BIT

//****************************************************************************** 
// Automated Hardware Platform Detection 
//******************************************************************************

#if defined(_M_IX86) ||  defined(__INTEL__) || 
    defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) 
  // x86 32bit
#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || 
      defined(__amd64) || defined(__amd64__)
  // x86-64
#elif defined(__IA64__)
  // IA64
#elif defined(__ALPHA__)
  // DEC Alpha
#elif defined(__POWERPC__)
  // Motorola Power PC
#elif defined(__LITTLE_ENDIAN__)
  // Any other little endian
#elif defined(__BIG_ENDIAN__)
  // Any other big endian
#endif


//****************************************************************************** 
// Automated Operating System Detection 
//******************************************************************************

#if defined(__MSDOS__) || defined(_MSDOS)
  // DOS 16 bit
#elif defined(_WIN16)
  // Windows 16 bit
#elif defined(_WIN32) || defined(__WINDOWS__)
  // 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 defined(__APPLE__) || defined(__DARWIN__) || defined(__MACH__)
  // define something for Mac OS (32-bit and 64-bit, this part is common)
  #if TARGET_IPHONE_SIMULATOR
    // iOS Simulator
  #elif TARGET_OS_IPHONE
    // iOS Device
  #elif TARGET_OS_MAC
    // Other Kinds Of Mac OS
  #endif
#elif defined(__ANDROID__)
  // android
#elif defined(__BSD__) || defined(__FREEBSD__) 
  // BSD
#elif defined(__linux__)
  // define something for linux (32-bit and 64-bit, this part is common)
  //  Linux Subsystem: Ubuntu, Solaris, Redhat, RHEL, CentOS, Fedora, Arch Linux, 
  //                   Debian, openSUSE, Flatpak, Solus*, FreeBSD*, 红旗Linux
  #ifif defined(__LP64__) || defined(__amd64) //|| defined(__amd64__)
    // define something for linux (64-bit only)
  #else
    // define something for linux (32-bit only)
  #endif
#elif defined(__OS2__)
  // OS/2
#elif defined(__unix__)// all unices not caught above
  // Unix
#elif defined(_POSIX_VERSION)
  // POSIX
#else
  // KDE Neon, Windows ICE, Windows Phone, Windows Subsystem for Linux(简称WSL), HarmonyOS
  #error "Unknown"
#endif

// Define __WIN16__ platform indicator 
#ifdef _Windows_ 
#ifndef __NT__ 
#define __WIN16__ 
#endif 
#endif

// _WIN32 is used by 
// Visual C++ 
#ifdef _WIN32 
#define __NT__ 
#endif

// Define __MAC__ platform indicator 
#ifdef macintosh 
#define __MAC__ 
#endif

// Define __OSX__ platform indicator 
#ifdef __APPLE__ 
#define __OSX__ 
#endif

// Define Windows CE platform indicator 
#ifdef WIN32_PLATFORM_HPCPRO 
#define __WINCE__ 
#endif

#if (_WIN32_WCE == 300) // for Pocket PC 
#define __POCKETPC__ 
#define __WINCE__ 
//#if (_WIN32_WCE == 211) // for Palm-size PC 2.11 (Wyvern) 
//#if (_WIN32_WCE == 201) // for Palm-size PC 2.01 (Gryphon)  
//#ifdef WIN32_PLATFORM_HPC2000 // for H/PC 2000 (Galileo) 
#endif


//****************************************************************************** 
// Automated Windows System Version Detection 
//*************************
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值