What macros are predefined by gcc?

Digging through the gcc man page, I found this question can be answered by the following command:

touch foo.h; cpp -dM foo.h

I’ve known this several times before, but I can never remember it, and the gcc man page is rather long, and so it can be a pain to find it again. I need to come up with some mnemonic way of remembering it. What are the defined Macros, o’ dungeon Master? Eh… that’s probably not going to work. Maybe writing it down here on this blog will help me next time I forget.

The output of that command on my system is:

#define __DBL_MIN_EXP__ (-1021)
#define __FLT_MIN__ 1.17549435e-38F
#define __CHAR_BIT__ 8
#define __WCHAR_MAX__ 2147483647
#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
#define __FLT_EVAL_METHOD__ 2
#define __DBL_MIN_10_EXP__ (-307)
#define __FINITE_MATH_ONLY__ 0
#define __GNUC_PATCHLEVEL__ 2
#define __SHRT_MAX__ 32767
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define __UINTMAX_TYPE__ long long unsigned int
#define __linux 1
#define __unix 1
#define __LDBL_MAX_EXP__ 16384
#define __linux__ 1
#define __SCHAR_MAX__ 127
#define __USER_LABEL_PREFIX__ 
#define __STDC_HOSTED__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __DBL_DIG__ 15
#define __FLT_EPSILON__ 1.19209290e-7F
#define __LDBL_MIN__ 3.36210314311209350626e-4932L
#define __unix__ 1
#define __DECIMAL_DIG__ 21
#define __gnu_linux__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __GNUC__ 4
#define __DBL_MAX__ 1.7976931348623157e+308
#define __DBL_HAS_INFINITY__ 1
#define __DBL_MAX_EXP__ 1024
#define __LONG_LONG_MAX__ 9223372036854775807LL
#define __GXX_ABI_VERSION 1002
#define __FLT_MIN_EXP__ (-125)
#define __DBL_MIN__ 2.2250738585072014e-308
#define __DBL_HAS_QUIET_NAN__ 1
#define __REGISTER_PREFIX__ 
#define __NO_INLINE__ 1
#define __i386 1
#define __FLT_MANT_DIG__ 24
#define __VERSION__ "4.1.2 20070925 (Red Hat 4.1.2-33)"
#define i386 1
#define unix 1
#define __i386__ 1
#define __SIZE_TYPE__ unsigned int
#define __ELF__ 1
#define __FLT_RADIX__ 2
#define __LDBL_EPSILON__ 1.08420217248550443401e-19L
#define __GNUC_RH_RELEASE__ 33
#define __LDBL_DIG__ 18
#define __FLT_HAS_QUIET_NAN__ 1
#define __FLT_MAX_10_EXP__ 38
#define __LONG_MAX__ 2147483647L
#define __FLT_HAS_INFINITY__ 1
#define linux 1
#define __LDBL_MANT_DIG__ 64
#define __WCHAR_TYPE__ long int
#define __FLT_DIG__ 6
#define __INT_MAX__ 2147483647
#define __FLT_MAX_EXP__ 128
#define __DBL_MANT_DIG__ 53
#define __WINT_TYPE__ unsigned int
#define __LDBL_MIN_EXP__ (-16381)
#define __LDBL_MAX_10_EXP__ 4932
#define __DBL_EPSILON__ 2.2204460492503131e-16
#define __INTMAX_MAX__ 9223372036854775807LL
#define __FLT_DENORM_MIN__ 1.40129846e-45F
#define __FLT_MAX__ 3.40282347e+38F
#define __FLT_MIN_10_EXP__ (-37)
#define __INTMAX_TYPE__ long long int
#define __GNUC_MINOR__ 1
#define __DBL_MAX_10_EXP__ 308
#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
#define __STDC__ 1
#define __PTRDIFF_TYPE__ int
#define __LDBL_MIN_10_EXP__ (-4931)
#define __GNUC_GNU_INLINE__ 1

Neat-o.

~ by scaryreasoner on August 1, 2008.

7 Responses to “What macros are predefined by gcc?”

  1. Yeah, now it can be googled in perpetuity! The more I read of this the more I don’t miss vi and gcc. I’ve become so spoiled by Visual Studio and C#. Say what you want about Microsoft, Visual Studio rocks as a development platform!

  2. Uh, ok Doubting Foo. Kind of a strange comment. I’m glad you like the development environment you use. I like the one I use too.

    “Say waht I want about Mircrosoft?” Prior to the previous sentence, I’ve mentioned Microsoft zero times on this blog. Are you suggesting that I need to talk about Microsoft more?

  3. […] 9, 2008 in C++, GCC I recently stumbled across an article referencing macros defined by gcc. That list is pretty daunting! If you compare it to GCC Common Predefined Macros (the official […]

    • agree, there are tons of macros I cannot find on the docs under the common predefined macros section, for instance `__i386__`. Does anyone know where that one is located?

  4. This was very helpful. Thankyou reasoner. That’s very interesting browsing the list of “things you can know from inside a C program”.

  5. I prefer “echo | gcc -dM -E -” myself, because there is no need to create an intermediary file.

  6. I think the cleanest is `cpp -dM /dev/null`, no need to create a file, and the most direct approach.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: