How can I get a list of all preprocessor symbols used (or defined) within a file?

天大地大妈咪最大 提交于 2020-01-23 08:17:27

问题


I have a number of C/C++ project files. I'd like to know the full list of preprocessor symbols used by the files. Is there a flag to gcc, or is there some tool I can use to get this list.

Optionally, if the tool also told me the list of symbols defined by the file, that would be great.


回答1:


Use gcc -E -dM <file_list> - preprocess, then output #defines.

My gcc is a tad rusty, so I'm not sure whether or not you explicitly need the -E, but try both?

For further reference, see this



来源:https://stackoverflow.com/questions/5603870/how-can-i-get-a-list-of-all-preprocessor-symbols-used-or-defined-within-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!