GCC 预处理器删除注释

标签 gcc c-preprocessor

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

最佳答案

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 `#'.

关于GCC 预处理器删除注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2208515/

相关文章:

C++ Makefile LD 错误

C:另一种(更好的)编译文件的方法?

c++ - noexcept 运算符和 enable_if_t : do they work together?

c - #Define 带参数的整个函数调用?

objective-c - 用于配置的 XCode 预处理器宏?

c - 使用嵌套函数编译c文件时出现错误

gcc - Bison 解析器总是打印 "syntax error"

c - 有没有办法检查 C/C++ 中预处理器符号值的类型

c - 如何在 fprintf 中使用 Variadic 宏

c - 如何编写类似 foreach 的宏来访问图形的所有节点