Skip to content

Commit fb4642c

Browse files
committed
Updated getting started page and screenshots. Added IntelliSense engine.md
1 parent 43dba74 commit fb4642c

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed

Documentation/Getting started.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
# Getting started
22

3-
## Configuring IntelliSense
3+
## Configuring includePath for better IntelliSense results
44

5-
**Quick summary**: Open your settings file and add `"C_Cpp.intelliSenseEngine": "Default"` to preview the new and improved IntelliSense. Then add the necessary include paths and preprocessor defines to your c_cpp_properties.json file so that IntelliSense can find your symbols.
5+
This page describes how to configure include paths for folders containing C or C++ files to get better IntelliSense experience. If you're seeing the following message when opening a folder in VS Code, it means the C++ IntelliSense engine needs additional information about the paths in which your symbols are located.
66

7-
#### The IntelliSense engines
7+
![Configure includePath for better IntelliSense](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Configure%20includePath.PNG)
88

9-
When the extension was first released, we shipped an IntelliSense engine that provided quick, but "fuzzy" results for common operations like auto-complete, parameter help, quick info tooltips, and goto definition. This "tag parser" built up a database of symbols by parsing the most important "tags" from your source files, ignoring preprocessor blocks, local variables, and most errors. More recently, we have begun the process of porting the MSVC IntelliSense engine from Visual Studio to VS Code to provide more accurate results.
9+
#### Where to configure the include paths
1010

11-
You can choose the engine that works best for your projects by editing your [user or workspace settings](https://code.visualstudio.com/docs/getstarted/settings). The setting you should modify is `"C_Cpp.intelliSenseEngine"`. There are two values for this setting:
11+
When you open a folder, the extension will attempt to locate your system headers based on your operating system, but it does not know about any auxiliary libraries that your project depends on. You can specify the remaining paths by either using the `"C/Cpp: Edit Configurations"` command in the command palette, or by selecting `"Edit "includePath" setting"` in the lightbulb menu (see the screenshot below). The quickiest way to locate the lightbulb is to scroll to the top of the source file and click on any green squiggle, which usually shows up at the first line in the file).
1212

13-
* `"Default"` - use Visual Studio's IntelliSense engine (in preview, the default for VS Code Insiders)
14-
* `"Tag Parser"` - use the "fuzzy" IntelliSense engine (the default for users on the stable VS Code build)
13+
![lightbulb menu "Edit "includePath" setting"](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Lightbulb.png)
1514

16-
#### Include paths
15+
This creates or opens a file called **c_cpp_properties.json** in the .vscode directory in the opened folder in your workspace. In this file, you can specify the paths to the headers that your project depends on. Look for the section where your current configuration is defined (by default there's one configuration per OS, such as "Win32 or "Mac"), and add your paths in the `"includePath"` setting and defines in the `"defines"` setting. For example, the following screenshot shows a snippet of the file specifying path for the Mac configuration.
1716

18-
In order to get accurate IntelliSense results with either engine, the extension needs some information about your project. When you open a folder, the extension will attempt to locate your system headers based on your operating system, but it does not know about any auxiliary libraries that your project depends on. You can specify the remaining paths by using the `"C/Cpp: Edit Configurations"` command in the command palette.
17+
![c_cpp_properties file snippet](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/c_cpp_properties%20file.PNG)
1918

20-
This command will create or open a file called **c_cpp_properties.json** in your workspace. In this file, you can specify the paths to the headers that your project depends on. There are two settings in this file that you should pay particular attention to: `"includePath"` and `"browse.path"`. `"includePath"` is the setting used by the `"Default"` IntelliSense engine and `"browse.path"` is the setting used by the tag parser engine. [More information about these settings is documented here](https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/FAQ.md#what-is-the-difference-between-includepath-and-browsepath-in-c_cpp_propertiesjson).
19+
If your build system is able to produce a compile_commands.json file, which can be auto-generated by build systems such as CMake and Ninja, the extension can get the information for the `"includePath"` and `"defines"` from that. Set the `"compileCommands"` property to the full path to your compile_commands.json file and the extension will use that instead of the `"includes"` and `"defines"` properties for IntelliSense.
20+
![use compileCommands setting](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/compile_commands.png)
2121

22-
If your build system is able to produce a compile_commands.json file, the extension can get the information for the `"includePath"` and `"defines"` from that. Set the `"compileCommands"` property to the full path to your compile_commands.json file and the extension will use that instead of the `"includePath"` and `"defines"` properties for IntelliSense. You should still set the `"browse.path"` property since code navigation uses that property.
22+
#### Understand which headers can't be located
23+
24+
To figure out which headers you need to specify paths for, you can either hover over the green squiggles to see the message in the tooltip, or open the Problems window to see the errors listed there. The error messsages show which headers the IntelliSense engine is unable to open - it could be the headers that are being included directly or the headers that the included headers are dependent on. The following screenshot shows an example of the error message being shown in the tooltip as well as the Problems window.
25+
26+
![include error message](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Include%20errors.png)
27+
28+
#### Use the lightbulb suggestions to auto-resolve includePath
29+
30+
You can also leverage the lightbulb path suggestions lightbulb to auto-resolve the included file. When you open a folder, the extension will **recursively** search for potential include paths that match the header files your code is using based on the paths set by the `"browse.path"` setting in **c_cpp_properties.json**. Click on the green squiggles under #include statements and a lightbulb will appear and offer suggestions of paths that will allow IntelliSense to resolve the included file.
31+
32+
![lightbulb suggestions](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/lightbulb%20suggestions.png)
33+
34+
#### Verify the include paths are correctly resolved
35+
36+
There are two ways to verify that the include paths are correctly resolved:
37+
38+
1. The green squiggles in the source file are no longer showing
39+
2. Error messages are cleared in the Problems window
40+
41+
This indicates that the IntelliSense engine has got the include paths resolved so you can start enjoying the full IntelliSense for your C or C++ code for the current translation unit. Note that you may still see errors on other files if they belong to a different translation unit that requires additional include paths to be configured.
42+
43+
#### See Also
44+
45+
[IntelliSense engines](https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/IntelliSense%20engine.md)
46+
[c_cpp_properties.json](https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/c_cpp_properties.json.md)
2347

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#### The IntelliSense engines
2+
3+
When the extension was first released, we shipped an IntelliSense engine that provided quick, but "fuzzy" results for common operations like auto-complete, parameter help, quick info tooltips, and goto definition. This "tag parser" built up a database of symbols by parsing the most important "tags" from your source files, ignoring preprocessor blocks, local variables, and most errors. More recently, we have begun the process of porting the MSVC IntelliSense engine from Visual Studio to VS Code to provide more accurate results.
4+
5+
You can choose the engine that works best for your projects by editing your [user or workspace settings](https://code.visualstudio.com/docs/getstarted/settings). The setting you should modify is `"C_Cpp.intelliSenseEngine"`. There are two values for this setting:
6+
7+
* `"Default"` - use Visual Studio's IntelliSense engine (in preview, the default for VS Code Insiders)
8+
* `"Tag Parser"` - use the "fuzzy" IntelliSense engine (the default for users on the stable VS Code build)
9+
10+
There are two settings in this file that you should pay particular attention to: `"includePath"` and `"browse.path"`. `"includePath"` is the setting used by the `"Default"` IntelliSense engine and `"browse.path"` is the setting used by the tag parser engine. [More information about these settings is documented here](https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/FAQ.md#what-is-the-difference-between-includepath-and-browsepath-in-c_cpp_propertiesjson).
11+
12+
#### The fallback

Images/c_cpp_properties file.PNG

-17.6 KB
Loading

Images/compile_commands.png

-24.5 KB
Loading

Images/lightbulb suggestion.png

15 KB
Loading

0 commit comments

Comments
 (0)