Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 917
Paul Biggar Avatar asked Feb 25 '23 13:02

Paul Biggar


1 Answers

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

like image 71
Ben Stott Avatar answered Mar 05 '23 16:03

Ben Stott