Skip to content

Commit b1e40a4

Browse files
authored
Merge pull request #2005 from Microsoft/seanmcm/0_17_1_release
Seanmcm/0 17 1 release
2 parents 8c6a167 + 7d4aed2 commit b1e40a4

19 files changed

+645
-374
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#### Old information (it still works, but is no longer recommended):
2+
3+
Logging is controlled by environment variables and is disabled by default. To enable logging, launch VS Code from an environment that contains the following variables:
4+
5+
```
6+
VSCODE_CPP_LOGDIR=c:\path\to\logfolder
7+
VSCODE_CPP_LOGFILE_LEVEL=5
8+
```
9+
10+
When you open your folder in VS Code, we will create a **vscode.cpp.log.\<pid\>.txt** file for each extension process launched (\<pid\> = process id).
11+
12+
The log file level is a number that determines how much detail we'll log. Level 5 is generally detailed enough to give us information about what is going on in your session. We don't recommend you set this higher than 7 since the log quickly becomes cluttered with information that doesn't really help us diagnose your issues and actually makes it harder for us to spot problems. It may also slow down the extension considerably and make it harder for you to reproduce your problem.
13+
14+
**Note:** You will likely need to reload the window or close VS Code to flush the contents of the log file since we do not flush the log after every call. If your log file seems to be empty, try reloading the window after you have followed the steps to reproduce your issue.
15+
16+
**Don't forget to remove the environment variables when you are finished providing us with the logs.** You wouldn't want the extension to needlessly spend CPU time and disk space writing data you don't need into log files.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Extension version 0.16.1 and earlier:
2+
3+
For developers using MinGW on Windows, we recommend you start with the following **c_cpp_properties.json** template. Select "C/Cpp: Edit Configurations" from the command palette to create this file if you haven't already.
4+
5+
In earlier versions of the extension, the `includePath` and a some system defines need to be set in order for IntelliSense to work properly. Note that you may have to change the MinGW version number to match what you have installed. Eg. `C:/MinGW/lib/gcc/mingw32/5.3.0/` instead of `C:/MinGW/lib/gcc/mingw32/6.3.0/`.
6+
7+
```json
8+
{
9+
"configurations": [
10+
{
11+
"name": "MinGW",
12+
"intelliSenseMode": "clang-x64",
13+
"includePath": [
14+
"${workspaceRoot}",
15+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
16+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32",
17+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/backward",
18+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
19+
"C:/MinGW/include",
20+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
21+
],
22+
"defines": [
23+
"_DEBUG",
24+
"__GNUC__=6",
25+
"__cdecl=__attribute__((__cdecl__))"
26+
],
27+
"browse": {
28+
"path": [
29+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
30+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
31+
"C:/MinGW/include/*",
32+
"${workspaceRoot}"
33+
],
34+
"limitSymbolsToIncludedHeaders": true,
35+
"databaseFilename": ""
36+
}
37+
}
38+
]
39+
}
40+
```
41+
42+
The `includePath` above includes the system header paths that gcc uses in version 6.3.0 for C++ projects and matches the output of `"gcc -v -E -x c++ nul"`. The `intelliSenseMode` should be set to **"clang-x64"** to get MinGW projects to work properly with IntelliSense. The `__GNUC__=#` define should match the major version of the toolchain in your installation (6 in this example).
43+
44+
For C projects, simply remove the C++ lines:
45+
46+
```json
47+
{
48+
"configurations": [
49+
{
50+
"name": "MinGW",
51+
"intelliSenseMode": "clang-x64",
52+
"includePath": [
53+
"${workspaceRoot}",
54+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
55+
"C:/MinGW/include",
56+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed"
57+
],
58+
"defines": [
59+
"_DEBUG",
60+
"__GNUC__=6",
61+
"__cdecl=__attribute__((__cdecl__))"
62+
],
63+
"browse": {
64+
"path": [
65+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include",
66+
"C:/MinGW/lib/gcc/mingw32/6.3.0/include-fixed",
67+
"C:/MinGW/include/*",
68+
"${workspaceRoot}"
69+
],
70+
"limitSymbolsToIncludedHeaders": true,
71+
"databaseFilename": ""
72+
}
73+
}
74+
]
75+
}
76+
```
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Windows Subsystem for Linux
2+
3+
To use the Windows Subsystem for Linux with this extension you need to add a configuration to your **c_cpp_properties.json** file which adds the necessary header paths from within the WSL filesystem to the `includePath`.
4+
5+
Select "C/Cpp: Edit Configurations" from the command palette to create the **c_cpp_properties.json** file if you haven't already.
6+
7+
## Release
8+
9+
For developers using Ubuntu with the current version of WSL released with the Fall Creators Update, you can add the following configuration template to your **c_cpp_properties.json** file.
10+
11+
```json
12+
{
13+
"name": "WSL",
14+
"intelliSenseMode": "clang-x64",
15+
"includePath": [
16+
"${workspaceRoot}",
17+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5",
18+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5",
19+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5/backward",
20+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
21+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
22+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
23+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
24+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include"
25+
],
26+
"defines": [
27+
"__linux__",
28+
"__x86_64__"
29+
],
30+
"browse": {
31+
"path": [
32+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/c++/5",
33+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu/c++/5",
34+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
35+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
36+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
37+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
38+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*"
39+
],
40+
"limitSymbolsToIncludedHeaders": true,
41+
"databaseFilename": ""
42+
}
43+
}
44+
```
45+
46+
The `includePath` above includes the system header paths that gcc uses for C++ projects and matches the output of `gcc -v -E -x c++ - < /dev/null`. The intelliSenseMode should be set to **"clang-x64"** to get WSL projects to work properly with IntelliSense.
47+
48+
Note that `${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/` is the path to the root of the Ubuntu filesystem. This will be different if you are using a different distro. You can discover the paths to your distro's filesystem by using this handy PowerShell command:
49+
50+
```Powershell
51+
PS R:\> ($(get-appxpackage).PackageFamilyName | findstr /i 'SUSE Ubuntu') -replace '^', "$`{localappdata`}/Packages/"
52+
53+
${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
54+
${localappdata}/Packages/46932SUSE.openSUSELeap42.2_022rs5jcyhyac
55+
${localappdata}/Packages/46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac
56+
```
57+
58+
For C projects, simply remove the C++ lines:
59+
60+
```json
61+
{
62+
"name": "WSL",
63+
"intelliSenseMode": "clang-x64",
64+
"includePath": [
65+
"${workspaceRoot}",
66+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
67+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
68+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
69+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
70+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include"
71+
],
72+
"defines": [
73+
"__linux__",
74+
"__x86_64__"
75+
],
76+
"browse": {
77+
"path": [
78+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
79+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/local/include",
80+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
81+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/x86_64-linux-gnu",
82+
"${localappdata}/Packages/CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc/LocalState/rootfs/usr/include/*"
83+
],
84+
"limitSymbolsToIncludedHeaders": true,
85+
"databaseFilename": ""
86+
}
87+
}
88+
```
89+
90+
### Beta
91+
92+
For developers using Bash on Ubuntu on Windows with the beta version of WSL from before the Fall Creators Update, you can add the following configuration template to your **c_cpp_properties.json** file.
93+
94+
```json
95+
{
96+
"name": "WSL (Beta)",
97+
"intelliSenseMode": "clang-x64",
98+
"includePath": [
99+
"${workspaceRoot}",
100+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
101+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
102+
"${localappdata}/lxss/rootfs/usr/include/c++/5/backward",
103+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
104+
"${localappdata}/lxss/rootfs/usr/local/include",
105+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
106+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
107+
"${localappdata}/lxss/rootfs/usr/include"
108+
],
109+
"defines": [
110+
"__linux__",
111+
"__x86_64__"
112+
],
113+
"browse": {
114+
"path": [
115+
"${localappdata}/lxss/rootfs/usr/include/c++/5",
116+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu/c++/5",
117+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include",
118+
"${localappdata}/lxss/rootfs/usr/local/include",
119+
"${localappdata}/lxss/rootfs/usr/lib/gcc/x86_64-linux-gnu/5/include-fixed",
120+
"${localappdata}/lxss/rootfs/usr/include/x86_64-linux-gnu",
121+
"${localappdata}/lxss/rootfs/usr/include/*"
122+
],
123+
"limitSymbolsToIncludedHeaders": true,
124+
"databaseFilename": ""
125+
}
126+
}
127+
```
128+
129+
The `includePath` above includes the system header paths that gcc uses for C++ projects and matches the output of `gcc -v -E -x c++ - < /dev/null`. The intelliSenseMode should be set to **"clang-x64"** to get WSL projects to work properly with IntelliSense.
130+
131+
Note that `${localappdata}/lxss/rootfs/` is the path to the root of the filesystem for Bash on Ubuntu on Windows.
132+
133+
For C projects, simply remove the C++ lines as in the previous example.
134+
135+
---
136+
137+
With these configurations, you should be all set up to use the new IntelliSense engine for linting, memberlist autocomplete, and quick info (tooltips). Add `"C_Cpp.intelliSenseEngine": "Default"` to your **settings.json** file to try out the new IntelliSense engine.
138+
139+
And remember to [heed the warnings of the Windows team about not creating or editing Linux files from a Windows app](https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-not-change-linux-files-using-windows-apps-and-tools/)!
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Customizing Default Settings
2+
3+
In version 0.17.0 we introduced new settings that allow you to override the extension's default values for properties set in **c_cpp_properties.json**.
4+
5+
## New VS Code settings
6+
7+
The following `C_Cpp.default.*` settings map to each of the properties in a configuration block of **c_cpp_properties.json**. Namely:
8+
9+
```
10+
C_Cpp.default.includePath : string[]
11+
C_Cpp.default.defines : string[]
12+
C_Cpp.default.compileCommands : string
13+
C_Cpp.default.macFrameworkPath : string[]
14+
C_Cpp.default.forcedIncludes : string[]
15+
C_Cpp.default.intelliSenseMode : string
16+
C_Cpp.default.compilerPath : string
17+
C_Cpp.default.cStandard : c89 | c99 | c11
18+
C_Cpp.default.cppStandard : c++98 | c++03 | c++11 | c++14 | c++17
19+
C_Cpp.default.browse.path : string[]
20+
C_Cpp.default.browse.databaseFilename : string
21+
C_Cpp.default.browse.limitSymbolsToIncludedHeaders : boolean
22+
```
23+
24+
These settings have all of the benefits of VS Code settings, meaning that they can have default, "User", "Workspace", and "Folder" values. So you can set a global value for `C_Cpp.default.cppStandard` in your "User" settings and have it apply to all of the folders you open. If any one folder needs a different value, you can override the value by adding a "Folder" or "Workspace" value.
25+
26+
This property of VS Code settings allows you to configure each of your workspaces independently - making the **c_cpp_properties.json** file optional.
27+
28+
## Updated **c_cpp_properties.json** syntax
29+
30+
A special variable has been added to the accepted syntax of **c_cpp_properties.json** that will instruct the extension to insert the value from the VS Code settings mentioned above. If you set the value of any setting in **c_cpp_properties.json** to "${default}" it will instruct the extension to read the VS Code default setting for that property and insert it. For example:
31+
32+
```
33+
"configurations": [
34+
{
35+
"name": "Win32",
36+
"includePath": [
37+
"additional/paths",
38+
"${default}"
39+
],
40+
"defines": [
41+
"${default}",
42+
],
43+
"macFrameworkPath": [
44+
"${default}",
45+
"additional/paths"
46+
],
47+
"forceInclude": [
48+
"${default}",
49+
"additional/paths"
50+
],
51+
"compileCommands": "${default}",
52+
"browse": {
53+
"limitSymbolsToIncludedHeaders": true,
54+
"databaseFilename": "${default}",
55+
"path": [
56+
"${default}",
57+
"additional/paths"
58+
]
59+
},
60+
"intelliSenseMode": "${default}",
61+
"cStandard": "${default}",
62+
"cppStandard": "${default}",
63+
"compilerPath": "${default}"
64+
}
65+
],
66+
```
67+
68+
Take note that for the properties that accept string[], the syntax proposed above allows you to augment the VS Code setting with additional values, thus allowing you to have common paths listed in the VS Code settings and configuration-specific settings in **c_cpp_properties.json**.
69+
70+
If a property is missing from **c_cpp_properties.json**, the extension will use the value in the VS Code setting. If a developer assigns values to all of the settings that apply for a given folder, then **c_cpp_properties.json** could be removed from the .vscode folder as it will no longer be needed.
71+
72+
### System includes
73+
74+
A new setting will be added that allows you specify the system include path separate from the folder's include path. If this setting has a value, then the system include path the extension gets from the compiler specified in the `compilerPath` setting will not be added to the path array that the extension uses for IntelliSense. We may want to provide a VS Code command to populate this value from the compiler's default for users who are interested in using it in case they want to make some modifications to the defaults.
75+
76+
```
77+
C_Cpp.default.systemIncludePath : string[]
78+
```
79+
80+
### Include Path Resolution Strategies
81+
82+
The extension determines the includePath to send to the IntelliSense engine in the following manner:
83+
84+
1. If `compileCommands` has a valid value and the file open in the editor is in the database, use the compile command in the database entry to determine the include path and defines.
85+
* The system include path and defines are determined using the following logic (in order):
86+
1. If `systemIncludePath` has a value, use it (continue to the next step to seach for system defines).
87+
2. If `compilerPath` is valid, query it.
88+
3. Interpret the first argument in the command as the compiler and attempt to query it.
89+
4. If `compilerPath` is `""`, use an empty array for system include path and defines.
90+
5. If `compilerPath` is undefined, look for a compiler on the system and query it.
91+
92+
2. If `compileCommands` is invalid or the current file is not listed in the database, use the `includePath` and `defines` properties in the configuration for IntelliSense.
93+
* The system include path and defines are determined using the following logic (in order):
94+
1. If `systemIncludePath` has a value, use it (continue to the next step to seach for system defines).
95+
2. If `compilerPath` is valid, query it.
96+
3. If `compilerPath` is `""`, use an empty array for system include path and defines (they are assumed to be in the `includePath` and `defines` for the current config already).
97+
4. If `compilerPath` is undefined, look for a compiler on the system and query it.
98+
99+
System includes should no longer be added to the `"includePath"` or `"browse.path"` variables. If the extension detects any system include paths in the `"includePath"` property it will silently remove them so that it can ensure system include paths are added last and in the correct order (this is especially important for GCC/Clang). In a future update we may add a notification message to the extension to remind developers to remove system include paths from their `"includePath"` and `'browse.path"` as they will be ignored.

0 commit comments

Comments
 (0)