Skip to content

Commit 03c6c4d

Browse files
committed
updated doc and screenshots
1 parent ab6b277 commit 03c6c4d

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

Documentation/Getting started.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
1-
# Getting started
1+
# Configuring includePath for better IntelliSense results
22

3-
## Configuring includePath for better IntelliSense results
3+
This page describes how to configure include paths for folders containing C or C++ files to get the full 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.
44

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.
5+
![Configure includePath for better IntelliSense](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/configure%20includepath.jpg)
66

7-
![Configure includePath for better IntelliSense](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Configure%20includePath.PNG)
7+
## Where to configure the include paths
88

9-
#### Where to configure the include paths
10-
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).
9+
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.
1210

1311
![lightbulb menu "Edit "includePath" setting"](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Lightbulb.png)
1412

1513
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.
1614

1715
![c_cpp_properties file snippet](https://github.com/Microsoft/vscode-cpptools/raw/ronglu-edit/Images/c_cpp_properties%20file.PNG)
1816

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/ronglu-edit/Images/compile_commands.png)
17+
You can either hover over the green squiggles to see the message in the tooltip, or open the Problems window to understand which headers the IntelliSense engine is unable to open.
2118

22-
#### Understand which headers can't be located
19+
![include error message](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Include%20errors.png)
2320

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.
21+
## Tips for setting up include paths quickly
2522

26-
![include error message](https://github.com/Microsoft/vscode-cpptools/raw/master/Images/Include%20errors.png)
23+
Manually configuring includes and defines could be time-consuming and sometimes cumbersome. It is recommended to try the following techniques to get the include paths setup automatically before resorting to manually configuring in the **c_cpp_properties.json** file.
2724

28-
#### Use the lightbulb suggestions to auto-resolve includePath
25+
#### 1. Use the lightbulb suggestions to auto-resolve includePath
2926

3027
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.
3128

3229
![lightbulb suggestions](https://github.com/Microsoft/vscode-cpptools/raw/ronglu-edit/Images/lightbulb%20suggestion.png)
3330

34-
#### Verify the include paths are correctly resolved
31+
#### 2. Use compile_commands.json file to supply includePaths and defines information
32+
33+
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.
34+
![use compileCommands setting](https://github.com/Microsoft/vscode-cpptools/raw/ronglu-edit/Images/compile_commands.png)
35+
36+
## Verify the include paths are correctly resolved
3537

3638
There are two ways to verify that the include paths are correctly resolved:
3739

@@ -40,7 +42,7 @@ There are two ways to verify that the include paths are correctly resolved:
4042

4143
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.
4244

43-
#### See Also
45+
## See Also
4446

4547
[IntelliSense engines](https://github.com/Microsoft/vscode-cpptools/blob/ronglu-edit/Documentation/LanguageServer/IntelliSense%20engine.md)
4648

Images/Include errors.png

-168 Bytes
Loading

Images/Lightbulb.png

20 Bytes
Loading

Images/configure includepath.jpg

14 KB
Loading

0 commit comments

Comments
 (0)