If you hover over an undeclared identifier in C/C++, choose "Add include" from a refactoring menu (Shift+Alt+Q) to insert the appropriate directive.
The 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—a refactoring menu, Visual Assist has not parsed the 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.
Note: 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 stable, and 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:
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:
If you tell Visual Assist to limit header files to filenames, i.e., omits paths, the example directives become:
If you tell Visual Assist to use only double quotes and limit header files to filenames, the example directives become:
You can specify your preferred style—token and filename—in the options dialog of Visual Assist.
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.
|AddIncludePreferShortestRelativePath||Make Add Include refrain from giving precedence to shortest path|
|AddIncludeTokenStyle||Make Add Include use a specific token or include by filename|
|DefaultAddIncludeDelimiter||Set fallback path delimiter for Add Include|