7

Sorry for the what I am sure is a basic question, but I must not be using the right terms when searching for an answer with code that has hundreds of header files. Simply searching the files for #define statements is tedious. Is there an easy way in Visual Studio or VSCode to just have it step through the files and give me a list of all values literals and their values?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Steven
  • 181
  • 8
  • This is not a simple question. As an example, consider `#ifdef FOO #define BAR FOO #else #define FOO 42`. How `FOO` is defined depends on `BAR`. Practically, this means you can't analyze headers in isolation, only Translation Units. And that means you get many dependencies on header guards (`#ifndef FOO_H_INCLUDED_ #define FOO_H_INCLUDED_ ... #endif // FOO_H_INCLUDED_`) – MSalters Mar 24 '20 at 10:45
  • 1
    Does this answer your question? [GCC dump preprocessor defines](https://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines) – Lanting Mar 24 '20 at 10:49

1 Answers1

2

The closest you can get is to use the /P compiler switch to dump the preprocessed output to a file. It's going to be pretty huge, but it shows you precisely what the compiler is working with, and you can do a text search in the output file to find what you're looking for.

tenfour
  • 36,141
  • 15
  • 83
  • 142