Is there a way to omit the definitions (line markers) at the top of the C-preprocessor output?

后端 未结 1 1396
情话喂你
情话喂你 2021-01-17 22:15

If I process the following test.def input file with gcc -C -x c -E test.def:

#define TEST foo 
int TEST;

I would

相关标签:
1条回答
  • 2021-01-17 22:33

    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.

    0 讨论(0)
提交回复
热议问题