C/C++: How to figure out the chain of header files for a given definition?

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?

Answers


  1. Right click project, "Project Properties"
  2. "Configuration Properties" -> "C/C++" -> "Advanced".
  3. Set "Show Includes" to "Yes".

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.


Need Your Help

List separate IP addresses on different lines

ios swift uitableview ip

I have an app that retrieves the IPV4 and IPV6 addresses and as of now, the addresses are all run together in the UITableView. How do I list them on different lines? Below is my code.

Bypassing devise signin when user registered via REST call

ruby-on-rails rest devise

I am using devise with rest enabled. I have a form that requires user authentcation / registration. The authentication is implemented in fancybox light box.