Visual Studio Gem #1 - Include Files
Filed under Programming
Tracking down how an include file (.h) got into your project can be painful.
It's obvious if the include file is #include'ed by one of your files. It's less obvious when the include file is brought in by nested includes. Also, some include files are enclosed in #ifdef XXXX/#endif which requires knowledge of macro XXXX in order to determine if this code path is actually used.
There's a better way!
Go to...
Microsoft Visual Studio->Project->Properties...->Configuration Properties->C/C++->Advanced->Show Includes
Set this option to "Yes."
When you compile your files, the Output window will show you:
- Every include file
- The order include files are parsed
- The parent include file via indentation
For example, in the above Output window, stdafx.h brings in targetver.h and windows.h. Windows.h brings in sdkddver.h and excpt.h.
Here's what stdafx.h looks like for reference...
You don't want this option on all the time because it will really pollute your output window and slow things down with massive amounts of information.
This setting can also be helpful in determining what include files should be part of your precompiled headers.