无论如何查看预处理器定义宏的列表? [英] Anyway to see list of preprocessor defined macros?

查看:162
本文介绍了无论如何查看预处理器定义宏的列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望看到通过调用我正在使用的编译器定义的所有宏。有没有办法做到这一点?我在手册中看到它说你可以使用 cpp -dM 但这不适用于我。也许我做错了什么?

I'd like to see all macros that are defined by the invocation of the compiler I'm using. Is there any way to do this? I have seen in the manual it says you can use cpp -dM but this doesn't work for me. Perhaps I'm doing something wrong?

当我运行时:

When I run:

cpp -dM

我根本没有从预处理器中得到任何输出。如果我尝试在gcc上添加 -dM 作为选项,我没有注意到任何区别。

I get no output at all from the preprocessor. If I try adding -dM as an option on gcc, I don't notice any difference.

推荐答案

您可以使用:

You can use:

gcc -dM -E - < /dev/null

请注意,您还可以使用此命令获得编译器宏:

Note that you can also get the compiler macros in addition with this command:

touch bla.c && gcc -dM -E bla.c

例如在我的电脑上:

$ touch bla.c && gcc -dM -E bla.c | wc -l
486
$ gcc -dM -E - < /dev/null | wc -l
124
$

这篇关于无论如何查看预处理器定义宏的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆