Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ include file browser

I have a very large project with tons of convoluted header files that all include each other. There's also a massive number of third-party libraries that it depends on. I'm trying to straighten out the mess, but I'm having some trouble, since a lot of the time I'll remove one #include directive only to find that the stuff it was including is still included through one of the other files. Is there any tool that can help me understand this? I'd really like to be able to click on a .h file and ask it which CPP files it's included in (directly or indirectly), and the paths through which it is included, and likewise click a cpp file and ask it which .h files are included (directly and indirectly). I've never heard of a tool that does this, and a bit of quick googling hasn't turned anything up, but maybe I don't know what to search for.

like image 430
rmeador Avatar asked Jul 13 '09 19:07

rmeador


People also ask

Can include a file in C?

The #include directive tells the C preprocessor to include the contents of the file specified in the input stream to the compiler and then continue with the rest of the original file. Header files typically contain variable and function declarations along with macro definitions.

Where does C look for include files?

GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.

How do I include a .h file in another folder?

You can find this option under Project Properties->Configuration Properties->C/C++->General->Additional Include Directories. and having it find it even in lib\headers. You can give the absolute or relative path to the header file in the #include statement.

What is an include path in C?

includePath An include path is a folder that contains header files (such as #include "myHeaderFile. h" ) that are included in a source file. Specify a list of paths for the IntelliSense engine to use while searching for included header files.


2 Answers

http://www.profactor.co.uk/includemanager.php

like image 96
Steve Folly Avatar answered Oct 26 '22 21:10

Steve Folly


For VS2003 there is /showIncludes flag (in C/C++/Advanced properties). This will print all headers each .cpp file includes and what they include, so you can go from there.

I'm sure there is same option in same place for VS2008.

like image 34
Eugene Avatar answered Oct 26 '22 21:10

Eugene