Created attachment 31484 [details] Example input and output files I've found that g++ 4.8.x preprocessor output unexpectedly includes comments meant for GNU C Library files. To illustrate this problem, I ran the g++ preprocessor on test.hpp using as follows g++ -C -E -o test-<gcc-version>.hpp -P test.hpp With g++ 4.7.3, this generated the expected output file. However, with g++ 4.8.0, 4.8.1, and 4.8.2 the generated output file unexpectedly contained a number of comments meant for GNU C Library files.
You are using -C, so what do you expect? Note that since 4.8.x GCC automatically includes stdc-predef.h (which you can see when you remove the -P option). The comment nicely explains in the last sentence: /* This header is separate from features.h so that the compiler can include it implicitly at the start of every compilation. It must not itself include <features.h> or any other header that includes <features.h> because the implicit include comes before any feature test macros that may be defined in a source file before it first explicitly includes a system header. GCC knows the name of this header in order to preinclude it. */ Thus, it works as designed. No?
Yeah, that is not a bug. With -ffreestanding, -nostdinc or -fpreprocessed <stdc-predef.h> isn't automatically included, but you then have to deal with the other effects of those options.
Richard and Jakub - Thanks for the quick response and explanation. I was able to use the -nostdinc option to suppress the automatic inclusion of <stdc-predef.h>, which eliminates the unwanted comments.