cpp is often (mis)used for non-C files, many Fortran projects for example prefer to run a separate preprocessor step by invoking cpp by hand instead of relying on the built-in preprocessing of the fortran compiler (don't ask why - I don't understand it either). In order not to mess up anything in the non-C file, cpp is usually invoked as cpp -C -P -traditional The "-C" flag started to make problems in recent versions(?), as this now emits a large comment header on every file: #> echo "asd" | cpp -C -P /* Copyright (C) 1991-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ /* 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. */ /* glibc's intent is to support the IEC 559 math functionality, real and complex. If the GCC (4.9 and later) predefined macros specifying compiler intent are available, use them to determine whether the overall intent is to support these features; otherwise, presume an older compiler has intent to support these features and define these macros by default. */ /* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) / Unicode 6.0. */ /* We do not support C11 <threads.h>. */ asd Would it be too much trouble to not include this extraneous header? Kind regards, Lorenz
Heh. Does this since 4.8. This is from stdc-predef.h we forcefully include in each translation unit. You can use -nostdinc to restore original behavior. Note that this bug will likely be closed as invalid/wontfix. OTOH the included comment says the file is LGPL which may have issues if it gets included in sth statically linked? I think we should change its license to BSD/MIT.
Oh, in my case stdc-predef.h comes from glibc thus the license comment should be directed there. The GCC shipped stuff seems to have the runtime exception.
https://gcc.gnu.org/gcc-4.8/porting_to.html suggests to use -ffreestanding Of course, the real fix for this and future issues arising from such mis-use is to make libcpp more general and enable cpp to have a "Fortran mode" (-x fortran) or even compile a Fortran version of cpp (fpp?). This would be a very valuable contribution to GCC and gfortran and, technically, it should be not very difficult: https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps
Well, IMHO if you do not want comments or are not prepared to handle them, just don't use -C. Fortran these days has integrated preprocessor, I doubt fpp would be of any use and you'd need to define how exactly should "fortran" preprocessing behave (e.g. how it is different from assembly preprocessing). Note that even -E -xassembler-with-cpp preprocessing includes stdc-predef.h by default, you need to use -nostdinc to avoid that. In any case, not a bug IMHO.