有没有办法省略 C 预处理器输出顶部的定义(行标记)?
Is there a way to omit the definitions (line markers) at the top of the C-preprocessor output?
如果我使用 gcc -C -x c -E test.def
处理以下 test.def
输入文件:
#define TEST foo
int TEST;
我希望输出为:
int foo;
相反,我得到:
# 1 "test.def"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.def"
int foo;
有什么方法可以省略顶部的那些额外行吗?
这些不仅在顶部 - 而且它们是 C 预处理器用来向 C 编译器传达某些行来自的源代码位置的行标记。
使用 GCC 这很容易,因为 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.
因此,使用gcc -E -P -x c
。
此外,我不会使用 -C
(保留注释),因为看起来 gcc
从隐式头文件中添加了一些注释。
如果我使用 gcc -C -x c -E test.def
处理以下 test.def
输入文件:
#define TEST foo
int TEST;
我希望输出为:
int foo;
相反,我得到:
# 1 "test.def"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "test.def"
int foo;
有什么方法可以省略顶部的那些额外行吗?
这些不仅在顶部 - 而且它们是 C 预处理器用来向 C 编译器传达某些行来自的源代码位置的行标记。
使用 GCC 这很容易,因为 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.
因此,使用gcc -E -P -x c
。
此外,我不会使用 -C
(保留注释),因为看起来 gcc
从隐式头文件中添加了一些注释。