linux下查看系统⾃⾝宏定义日耳曼语
跨平台程序,经常要⽤到区分系统的宏定义,⽐如windows中的WIN32, WIN64, 中的 unix, 等等系统⾃定义宏那么在linux下⾯,怎么查看系统有哪些⾃定义宏咧,⽤如下⽅法:
$ touch dummy.hxx
$ cpp -dM ./dummy.hxx
输出如下:
[xhq@syfh1-10-0-128-229 rver]$ cpp -dM ./dummy.hxx
#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 2147483647
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
#define __FLT_EVAL_METHOD__ 0
#define __unix__ 1
#define __x86_64 1
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 7
strike是什么意思#define __DEC64_MAX_EXP__ 385
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINTMAX_TYPE__ long unsigned int
#define __linux 1
#define __DEC32_EPSILON__ 1E-6DF
annotate#define __unix 1
#define __LDBL_MAX_EXP__ 16384
#define __linux__ 1
要查看全部,可以加less命令:
$ cpp -dM ./dummy.hxx | less
就可以光标向上翻或者向下翻,因为系统可能宏定义⽐较多,⼀屏看不过来
另附上各操作系统的平台宏定义
T ype Macro Description
Identification_AIX
Version _AIX'VR'V = Version
R = Revision
politicalIdentification__TOS_AIX__Defined by xlC Example
If _AIX is defined, then the following macros can be ud to determine the version. Notice that the macros indicates the mentioned version or higher. For example, if _AIX43 is defined, then _AIX41 will also be defined.
AIX Version Macro
3.2.x _AIX3 _AIX32
4.1_AIX41
4.3_AIX43
T ype Macro Format Description
Identification__ANDROID__
Version__ANDROID_API__V
V = API Version反馈英语
Must be included from <android/api-level.h> Notice that is bad on , and that the macros also are defined for .
Example
Android Version__ANDROID_API__
1.01
1.12
1.53
1.64
2.05
2.0.16
2.17
2.28
2.39
2.3.310
3.011state是什么意思
T ype Macro
Identification UTS
T ype Macro Description
Identification AMIGA
Identification__amigaos__Defined by GNU C
T ype Macro
Identification aegis
T ype Macro
Identification apollo
Bad on Nucleus OS.
T ype Macro
Identification__BEOS__
T ype Macro Description
Identification__bg__
All Blue Gene systems
Defined by XL C/C++ and GNU C Version__bgq__
Blue Gene/Q
Defined for XL C/C++ and GNU C Identification__THW_BLUEGENE__
All Blue Gene systems
Defined by XL C/C++
Version__TOS_BGQ__
Blue Gene/Q
Defined by XL C/C++
T ype Macro Format Description
Identification __FreeBSD__ __NetBSD__ __OpenBSD__ __bsdi__
__DragonFly__
Version BSD YYYYMM YYYY = Year
MM = Month
Must be included from <sys/param.h>
Version BSD4_2
很快英语BSD4_3
BSD4_4
Must be included from <sys/param.h>
Identification_SYSTYPE_BSD Defined by DEC C Example
Version BSD Macro 4.3 Net2199103
4.4199306BSD4_4 4.4BSD-Lite2199506
T ype Macro
Identification__bsdi__
T ype Macro
Identification__convex__
T ype Macro
Identification__CYGWIN__
T ype Macro
T ype Macro
Identification DGUX
contacts流木Identification__DGUX__
Identification__dgux__
T ype Macro
Identification__DragonFly__
T ype Macro
Identification_SEQUENT_
Identification quent
T ype Macro
Identification__ECOS
T ype Macro
Identification__EMX__
T ype Macro Format Description
Identification__FreeBSD__
Identification__FreeBSD_kernel__From FreeBSD 8.3, 9.1, and 10.0.
Version BSD
Version__FreeBSD__V V = Version
Version__FreeBSD_version?Must be included from <osreldate.h>
Example
FreeBSD__FreeBSD____FreeBSD_version
1.x1
2.0-RELEASE2119411
2.2-RELEASE2220000
3.0-RELEASE3300005
4.0-RELEASE4400017
4.5-RELEASE4450000
For more information e the .
GNU aka
The official name of this operating system is GNU. Hurd is the kernel in the GNU operating system. It is often listed as GNU/Hurd since there is also GNU/Linux and GNU/kFreeBSD, which are most of the GNU operating system with the Linux and FreeBSD kernels respectively.
T ype Macro
Identification__GNU__
Identification__gnu_hurd__
GNU/kFreeBSD is one of the Debian distros that is bad on the FreeBSD kernel rather than the Linux or Hurd kernels.
T ype Macro
Identification__FreeBSD_kernel__&&__GLIBC__
Notice that FreeBSD also defines __FreeBSD_kernel__ so the __GLIBC__ macro must be checked to distinguish it.
T ype Macro
Identification__gnu_linux__
T ype Macro
Identification__hiuxmpp
T ype Macro Description
Identification_hpux Defined by HP UPC
Identification hpux
Identification__hpux
T ype Macro
Identification__OS400__
T ype Macro
Identification__INTEGRITY
T ype Macro Description
Identification__INTERIX Defined by GNU C and Visual Studio
T ype Macro
Identification sgi
Identification__sgi
Systems bad on the Linux kernel define the macros. There are two major Linux-bad operating systems: and , and numerous others like or
T ype Macro Description
清华大学mbaIdentification__linux__
Identification linux Obsolete (not POSIX compliant)
Identification__linux Obsolete (not POSIX compliant)