If I process the following test.def
input file with gcc -C -x c -E test.def
:
#define TEST foo
int TEST;
I would like the output to be just:
int foo;
Instead I get:
# 1 "test.def"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.def"
int foo;
Is there a way I can omit those extra lines at the top?
These are not just on the top - but instead they're the line markers that the C preprocessors use to convey the source code positions where certain lines come from, to the C compiler.
With GCC this is easy, as GCC supports the -P
switch, and so does llvm Clang:
-P
. Inhibit generation of linemarkers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the linemarkers.
Thus, use gcc -E -P -x c
.
Also, I'd not use -C
(retain comments), as it seems that with it gcc
adds some comments from implicit header files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With