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.
Note: Except for a few system libraries such as MFC and CRT, Visual Assist can only suggest to include headers if it has parsed them. If "Add include" is missing from, or disabled in, a refactoring menu, add the 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 them other locations.
Umbrella Headers in C/C++
In most cases, Visual Assist adds the header that contains the definition of a symbol, not an umbrella header that includes it and other related headers. There are a few exceptions for several popular libraries, including Boost and Qt. In these cases, Visual Assist suggests adding the umbrella header.
Note: Except for a few system libraries such as MFC and CRT, Visual Assist can only suggest to include headers if it has parsed them, including the headers for Boost and Qt. Headers 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 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 headers to filenames only.
If you tell Visual Assist to use only double quotes, the example directives become:
If you tell Visual Assist to limit headers to filenames, i.e., omits paths, the example directives become:
If you tell Visual Assist to use only double quotes and limit headers 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 headers convenient but you should rely on compiler errors and your knowledge of header hierarchy to decide if a #include is required.
Do not to add headers needlessly. Visual Assist lets you add the header that contains the definition of a symbol even if you have already included an umbrella header.
|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|