Visual Assist can add include directives for headers that resolve unknown symbols in the current C++ source file.
Access
Hover over, or move the text caret to, an unknown symbol and access the Quick Action and Refactoring menu. Choose "Add include".
The necessary include directive is inserted after the last #include in your current file, outside of any ifdef directives. The position of the text caret is unchanged.
Except for a few system libraries such as MFC and CRT, Visual Assist can only suggest the including of header files it has parsed. If "Add include" is missing from—or disabled in—the Quick Action and Refactoring menu, Visual Assist has not parsed the needed header file.
Add appropriate directory(ies) to your project settings and manually include the directory(ies) somewhere in your project or solution. Once included in one location, Visual Assist can suggest including the header files in other locations.
Umbrella Header Files in C/C++
In most cases, Visual Assist adds the header that contains the definition of a symbol, not an umbrella header file that includes it and other related header files. There are a few exceptions for several popular libraries, including Boost and Qt. In these cases, Visual Assist suggests adding the umbrella header file.
Except for a few system libraries such as MFC and CRT, Visual Assist can only suggest to include header files if it has parsed them, including the header files for Boost and Qt. Header files for Boost or Qt should be listed in the VC++ Directories of your project so they are considered system symbols, and then included somewhere in a solution. Once included in one location, Visual Assist can suggest including them in other locations.
Add Include Style in C/C++
When using the Add Include feature, Visual Assist automatically determines an appropriate path to a header file and the tokens that surround it in an include directive. Example directives include:
#include "filename1.h"
#include "directory\filename1.h"
#include "..\filename1.h"
#include <filename2.h>
#include <directory\filename2.h>
You can tell Visual Assist to use only one token, i.e., double quote or angle bracket, and to limit header files to filenames only.
If you tell Visual Assist to use only double quotes, the example directives become:
#include "filename1.h"
#include "directory\filename1.h"
#include "..\filename1.h"
#include "filename2.h"
#include "directory\filename2.h"
If you tell Visual Assist to limit header files to filenames, i.e., omits paths, the example directives become:
#include "filename1.h"
#include <filename2.h>
If you tell Visual Assist to use only double quotes and limit header files to filenames, the example directives become:
#include "filename1.h"
#include "filename2.h"
You can specify your preferred style—token and filename—in the options dialog of Visual Assist.
Add Include Path in C/C++
By default, Visual Assist use the shortest possible path to the header. Change the behavior in the options dialog of Visual Assist.
Alternative settings are available to prefer a path without relative reference to a parent directory, or to a path relative to the project. For both alternates, Visual Assist uses the shortest possible if the preference is not possible.
If you select "Prefer path relative to project", ensure that the path of your project is in Additional Include Directories at Project | <Project Name> Properties | Configuration Properties | C/C++ | General.
File Delimiter
Visual Assist inserts include directives whose path delimiter, '/' or '\', is identical to the delimiter of existing include directives in the file. If the current file does not contain any include directives, or none of the existing directives use a path delimiter, Visual Assist uses a delimiter based on the current IDE.
Visual Studio 2010 and newer
Visual Assist respects the setting in the options dialog of the IDE.
Visual Studio 2008 and older
Set the fallback path delimiter in the registry.
Needless #includes in C/C++
Add Include makes the addition of header files convenient but you should rely on compiler errors and your knowledge of header file hierarchy to decide if a #include is required.
Do not to add header files needlessly. Visual Assist lets you add the header file that contains the definition of a symbol even if you have already included an umbrella header file.
Registry Settings