【问题标题】:Supress comments in output of "gcc -E" preprocessed code [duplicate]抑制“gcc -E”预处理代码输出中的注释[重复]
【发布时间】:2015-12-19 21:10:07
【问题描述】:

对于一个简单的 C 程序,我做了gcc -E hello.c -o hello.pp 来查看程序在预处理后的样子。

在输出文件中,我可以看到许多以# 开头的行,看起来像注释。这些线是什么?

我怎样才能只看到 C 代码,而没有那些 cmets?

下面是一个sn-p:

user $ gcc -E hello.c -o hello.pp
user $ tail -n 15 hello.pp

extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;

extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 943 "/usr/include/stdio.h" 3 4

# 3 "hello.c" 2
int main() 
{
     printf("Hello world \n");

     return 0;
}
user $ 

【问题讨论】:

  • 投票重新打开,因为原来的问题是 “我怎样才能只看到 C 代码,没有那些 cmets?”

标签: c gcc c-preprocessor


【解决方案1】:

“我怎样才能只看到 C 代码,而没有那些 cmets ?”

您可以使用 gcc 和选项 -E -P 来摆脱预处理器输出的 # 行。

来自gccdocumentation

-P

禁止在预处理器的输出中生成线标记。当在不是 C 代码的东西上运行预处理器时,这可能很有用,并且将被发送到可能被线标记混淆的程序。

【讨论】:

    猜你喜欢
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 2021-10-21
    • 2011-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多