GCC预处理器删除注释

时间:2010-02-05 16:09:25

标签: gcc c-preprocessor

是否可以指示GCC预处理器在处理文件时不删除注释?

3 个答案:

答案 0 :(得分:4)

GCC有-C选项来保留评论。

`-C'
     Do not discard comments.  All comments are passed through to the
     output file, except for comments in processed directives, which
     are deleted along with the directive.

     You should be prepared for side effects when using `-C'; it causes
     the preprocessor to treat comments as tokens in their own right.
     For example, comments appearing at the start of what would be a
     directive line have the effect of turning that line into an
     ordinary source line, since the first token on the line is no
     longer a `#'.

答案 1 :(得分:2)

是的,您可以使用-C选项执行此操作。 E.g。

gcc -C -E myfile.c

答案 2 :(得分:2)

man gcc并使用 / -C (斜线,空格,破折号,capitcal C)来减少(可能是你的寻呼机程序)搜索-C选项,使用< kbd> n 再次搜索(描述是第3次点击)。相关选项均在上方和下方。