In Visual C++, one can find the header file where any name (variable or type) is defined by pressing F12 on it or choosing Go to Definition. This feature is very useful, but it only shows the final location (header file) where the name is defined. Is there a way to figure out the chain of header files that lead from my source file to the final header file for a given name?
For example, consider this code:
// main.cpp
#include <stddef.h>
int main()
{
size_t s;
return 0;
}
In Visual C++ 2010, if I look up the definition of size_t
in the above main.cpp
, it lands me in some file named sourceannotations.h
. I know that this header chain begins with stddef.h
(which I have included) and ends in sourceannotations.h
. How to figure out the links in the middle of this chain?
The complete hierarchy of headers will be printed out in the output window when you compile every file.
You can use reverse engineering tools like Doxygen, Understand Analyst etc. This will help you understand the full flow of variables, function calls.
In your properties dialog, under C/C++, Preprocessor, enable Preprocess to a File. If you compile main.cpp, this will generate main.i.
You can then look in main.i and see which file includes what other file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With