如何仅在非 C/C 中使用 gcc 进行宏扩展++语境?
如何使用 gcc 来扩展包含(例如)python/php/perl 代码的文件中的宏?
有一个文件包含:
#define foo very important stuff
#define feast Christmas
I should take care of some foo for feast.
我尝试使用:
$ gcc -x c++ -E - < text.txt > output.txt
但它显示:
$ cat output.txt
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
I should take care of some very important stuff for Christmas.
如何避免 gcc 添加这些注释和(如果可能)额外的换行符?
How can I use gcc to expand macros in files containing (for example) python/php/perl code?
Having a file containing:
#define foo very important stuff
#define feast Christmas
I should take care of some foo for feast.
I have tried to use:
$ gcc -x c++ -E - < text.txt > output.txt
but it displays this:
$ cat output.txt
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "<stdin>"
I should take care of some very important stuff for Christmas.
How to avoid gcc to add those comments and (if possible) the extra newlines?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该注意GNU C 预处理器的在线文档中的此警告
输出中的“#”行可能是您遇到的问题中最少的。
使用不同的工具(例如 m4)可能会做得更好。
You should be aware of this warning from the online docs for the GNU C preprocessor
The '#' lines in the output could be the least of your problems.
You might do better with a different tool, such as m4.
我不知道gcc是否有特定的选项。
您可以使用 grep 进行后处理
I do not know if there is a specific option for gcc.
You can postprocess with a grep