GCC 预处理器删除注释

发布于 2024-08-20 22:41:22 字数 32 浏览 2 评论 0原文

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

Is it possible to instruct the GCC preprocessor not to remove comments when processing files?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少年亿悲伤 2024-08-27 22:41:22

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 has the -C option to preserve comments.

`-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 `#'.
画骨成沙 2024-08-27 22:41:22

是的,您可以使用 -C 选项来做到这一点。例如

gcc -C -E myfile.c

Yes, you can do it with the -C option. E.g.

gcc -C -E myfile.c
愛放△進行李 2024-08-27 22:41:22

man gcc 并使用 / -C (斜线、空格、破折号、大写 C)来减少(可能是你的寻呼机程序)搜索 -C 选项,使用n 再次搜索(描述是第三次命中)。相关选项在上面和下面。

man gcc and use / -C (slash, space, dash, capitcal C) to make less (which is probably your pager program) search for the -C option, use n to search again (the description is the 3rd hit). Related options are both above and below.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文