The -dM option is documented to provide a complete list of all defined macros, including all predefined macros, however the list is incomplete. In particular, the following will not list __STDC__ even though it is defined: touch test.h; gcc -dM test.h If you modify test.h to include: #ifdef __STDC__ #error __STDC__ is defined #endif The compilation will result in an error
Hmm, __STDC__ is treated special inside the preprocessor.
Actually this is a true bug and it was fixed in the past too: http://gcc.gnu.org/ml/gcc-patches/2001-02/msg01533.html I have to see where it started to fail now. Confirmed.
Hmm, when cpp0 was removed in 3.3, this was caused.
Your command line: touch test.h; gcc -dM test.h creates a precompiled header. Also, my documentation for -dM says: @item -dM @itemx -fdump-rtl-mach @opindex dM @opindex fdump-rtl-mach Dump after performing the machine dependent reorganization pass, to @file{@var{file}.35.mach}. What you want is -dD. But I'm not sure what that is supposed to write out. GCC 3.3, 4.0, and 4.1 all give no output at all for an empty file, or a file with a single #define.
I get a lot of output with: $ gcc -E -dD test.c Perhaps that is what you're looking for. This looks more like a documentation bug to me than a real preprocessor bug.
(In reply to comment #5) > I get a lot of output with: > $ gcc -E -dD test.c > > Perhaps that is what you're looking for. This looks more like a documentation > bug to me than a real preprocessor bug. It is not, -dD should include __STDC__ and it does in pre 3.3 but not post 3.3 when cpp0 went away. I forgot to update the summary when I confirmed it after fixing the testcase.
This is not critical, as it only affects secondary uses of the compiler.
Subject: Bug 25717 Author: jakub Date: Mon Jan 23 21:50:15 2006 New Revision: 110144 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110144 Log: PR preprocessor/25717 * init.c (cpp_init_builtins): If __STDC__ will not change value between system headers and other sources, define it as a normal macro rather than a builtin. * macro.c (_cpp_builtin_macro_text) <case BT_STDC>: Only check cpp_in_system_header condition. Modified: trunk/libcpp/ChangeLog trunk/libcpp/init.c trunk/libcpp/macro.c
Subject: Bug 25717 Author: jakub Date: Mon Jan 23 21:51:10 2006 New Revision: 110145 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110145 Log: PR preprocessor/25717 * init.c (cpp_init_builtins): If __STDC__ will not change value between system headers and other sources, define it as a normal macro rather than a builtin. * macro.c (_cpp_builtin_macro_text) <case BT_STDC>: Only check cpp_in_system_header condition. Modified: branches/gcc-4_1-branch/libcpp/ChangeLog branches/gcc-4_1-branch/libcpp/init.c branches/gcc-4_1-branch/libcpp/macro.c
Fixed in GCC-4.1.0 and higher.