0

I'm using some open source (MIT license) project that's composed of headers only. I'm using only a small fraction of what this project has to offer, and I'd hate to include all the headers in my project for no reason. I created a sample project and included the open source project in it. Is there any way to get a list of all the headers used by my sample project?

To clarify, in my sample project I have:

#include "opensourceMainHeader.h"

and opensourceMainHeader.h has:

#include "opensourceAuxiliaryHeader1.h"
#include "opensourceAuxiliaryHeader2.h"
#include "opensourceAuxiliaryHeader3.h"

And so on. Then I'd like to get (I'm guessing from the linker or some other tool chain in VC++) the list of headers that are used.

Is that possible?

Shmoopy
  • 5,334
  • 4
  • 36
  • 72
  • 1
    Not a duplicate, as this talks about finding the dependents for the entire project (based on C++) rather than a single C file. This question is also asked better than the other. It's also not asking for a tool recommendation as suggested by the other question nominated as a possible duplicate. This question is specific, answerable, and has appropriate detail. It should be voted up, not down. – Adrian McCarthy Jun 10 '15 at 15:24
  • I don't know whether it's available on Windows, but you might be interested in include-what-you-use, as in [my answer to "Self-sufficient header files in C/C++"](/a/30602408/4850040). – Toby Speight Jun 10 '15 at 15:57
  • I guess VC has an option /H since g++ has an option -H. (Undocumented: VC accepts dash options. Even the old -o) – Cheers and hth. - Alf Jun 10 '15 at 16:20
  • Checking on that, with VC the /H is something undocumented, and the option for listing include files is "/showIncludes" (yes, verbose) – Cheers and hth. - Alf Jun 10 '15 at 16:27

1 Answers1

1

There is a project setting in VS that can do this. Go to the Property Pages for your project, then Configuration Properties | C/C++ | All Options. Enable the Show Includes options. Build your project, and examine output. This is the /showIncludes option.

Chris O
  • 5,017
  • 3
  • 35
  • 42