From 4013f443284a03a5b817a6a8c3f172df11bfb8a0 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Wed, 23 Aug 2023 16:46:10 -0700 Subject: [PATCH 1/8] Add IntelliSense Configuration Doc --- docs/cpp/c-cpp-properties-schema-reference.md | 4 +- ...configure-intellisense-crosscompilation.md | 2 +- docs/cpp/configure-intellisense.md | 116 ++++++++++++++++++ docs/cpp/faq-cpp.md | 2 +- .../intellisense/compiler-quick-pick.png | 3 + .../configure-intellisense-indicator.png | 3 + .../intellisense/language-status-bar.png | 3 + 7 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 docs/cpp/configure-intellisense.md create mode 100644 docs/cpp/images/intellisense/compiler-quick-pick.png create mode 100644 docs/cpp/images/intellisense/configure-intellisense-indicator.png create mode 100644 docs/cpp/images/intellisense/language-status-bar.png diff --git a/docs/cpp/c-cpp-properties-schema-reference.md b/docs/cpp/c-cpp-properties-schema-reference.md index b38e3511cc..ee78ace653 100644 --- a/docs/cpp/c-cpp-properties-schema-reference.md +++ b/docs/cpp/c-cpp-properties-schema-reference.md @@ -4,14 +4,14 @@ Area: cpp TOCTitle: c_cpp_properties.json ContentId: EC1BA944-09B5-41EA-AAED-779A02C90C98 PageTitle: c_cpp_properties.json reference -DateApproved: 6/26/2020 +DateApproved: 8/23/2023 MetaDescription: Schema reference for C++ project settings in Visual Studio Code. --- # c_cpp_properties.json reference This article explains the scheme for the c_cpp_properties.json settings file. -For more information about changing these settings, see [Customizing Default Settings](/docs/cpp/customize-default-settings-cpp.md) and [Configure IntelliSense for cross-compiling](/docs/cpp/configure-intellisense-crosscompilation.md). +For more information about changing these settings, see [Customizing Default Settings](/docs/cpp/customize-default-settings-cpp.md) and [Configure IntelliSense](/docs/cpp/configure-intellisense.md). ## Example diff --git a/docs/cpp/configure-intellisense-crosscompilation.md b/docs/cpp/configure-intellisense-crosscompilation.md index 9038fbf251..4036067f70 100644 --- a/docs/cpp/configure-intellisense-crosscompilation.md +++ b/docs/cpp/configure-intellisense-crosscompilation.md @@ -1,5 +1,5 @@ --- -Order: 13 +Order: 14 Area: cpp TOCTitle: Configure IntelliSense for cross-compiling ContentId: 381b7ce1-5766-49b0-ad26-f9eedae70e63 diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md new file mode 100644 index 0000000000..82622911ff --- /dev/null +++ b/docs/cpp/configure-intellisense.md @@ -0,0 +1,116 @@ +--- +Order: 13 +Area: cpp +TOCTitle: Configure IntelliSense +ContentId: 381b7ce1-5766-49b0-ad26-f9eedae70e63 +PageTitle: Configure IntelliSense +DateApproved: 8/23/2023 +MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extension + +--- +# Configuring IntelliSense + +This article is about configuring the C/C++ extension to provide proper [IntelliSense](/docs/editor/intellisense.md). IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. + +IntelliSense is powered by a language service, which provides C++ specific language completions in your code. For the extension to provide correct IntelliSense suggestions, you need to configure the C/C++ extension. There are three types of sources that can be used for configuration: + +1. A C/C++ compiler +1. compile_commands.json file +1. Another extension (for example, the [Makefile](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake extension](/docs/cpp/CMake-linux.md)). + +## When is a compiler automatically configured? + +The C/C++ Extension, in most occasions, configures IntelliSense automatically for you. Common compiler paths in world writeable locations are queried on your machine, and if a compiler is available, are configured. If a compiler in a non-world writeable location is determined, a notification is displayed asking to configure this compiler. When approving compilers for IntelliSense, ensure that the compiler path is correct. Common compilers in their default world writeable locations that are automatically configured include the clang compiler, GCC, MinGW, and MSVC. If a compile_commands.json file or another extension that provides a configuration is found in your workspace, the extension will also automatically use these options to configure IntelliSense. + +## How to check whether IntelliSense is configured + +There are multiple options to determine your IntelliSense status: + +### Option 1: Check for a status bar indicator + + If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating "Configure IntelliSense". + +![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) + +To configure, simply select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). + +### Option 2: Check the language status bar + +To invoke the language status bar, open a C++ file. Note that the status bar now shows the text "{} C++". Hover over the "{}" symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: + +- "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and will automatically activate if you interact with the editor, for example, by writing code. +- "IntelliSense: Updating" = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code +- "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide your with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md) as explained below. + +![language-status-bar](images/intellisense/language-status-bar.png) + +### Option 3: Check the `c_cpp_properties.json` file + +All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the "IntelliSense mode" to understand your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). + +![Command Palette](images/cpp/command-palette.png) + +## How to configure IntelliSense + +If you have determined that IntelliSense isn't configured, you have multiple options to configure: + +### Option 1. Select a configuration option through the configuration Quick Pick + +Open the quick pick by entering **Select IntelliSense Configuration** in the Command Palette (`kb(workbench.action.showCommands)`), which shows you a dropdown with all of the configuration options found by the C/C++ Extension on your machine. + +![Compiler Quick Pick](images/intellisense/compiler-quick-pick.png) + +Select one of the options available. You can return to the Configuration Quick Pick at any point to change which option is being configured for IntelliSense. + +If no options are available in the quick pick, there are multiple options to install the right compiler. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the clang or GCC compiler installed on your machine. + +### Option 2. Edit the `c_cpp_properties.json` file + +You can edit the `c_cpp_properties.json` file directly to add your compiler or configuration option. Open the file by selecting **C/C++: Edit Configurations (JSON)** from the Command Palette (`kb(workbench.action.showCommands)`). Set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. + +If you prefer to access the `c_cpp_properties.json` file directly, use the "C/C++ Edit Configurations (JSON)" command from the Command Palette (`kb(workbench.action.showCommands)`) and updated the "compiler path" variable in the same manner. + +Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to "gcc-x64" or "clang-x64" to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). + +## Understanding the `c_cpp_properties.json` file + +The `c_cpp_properties.json` file is used to configure IntelliSense for the C/C++ Extension. It's located in the `.vscode` folder of your workspace. The C/C++ Extension automatically creates this file for you if you have a compiler installed in a world writeable location. If you don't have a compiler installed, you can create this file manually. The file contains fields such as: + +- Compiler path: The full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. +- IntelliSense mode: The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. +- Include path: You only need to modify the **Include path** if your program includes header files that aren't in your workspace or that aren't in the standard library path.The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually: + +For all of the fields in the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). + +Here's a sample `c_cpp_configuration.json` file on a Windows machine using the default install path for minGW: + +```json +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "windowsSdkVersion": "10.0.22621.0", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "${default}", + "compilerPath": "C:/msys64/mingw64/bin/gcc.exe" + } + ], + "version": 4 +} +``` + +## Next steps + +- For more information about IntelliSense configuration, see [Customizing default settings](/docs/cpp/customize-default-settings-cpp.md). +- If you have trouble configuring the settings, please start a discussion at [GitHub discussions](https://github.com/microsoft/vscode-cpptools/discussions), or if you find an issue that needs to be fixed, file an issue at [GitHub issues](https://github.com/microsoft/vscode-cpptools/issues). +- Explore the [c_cpp_properties schema](/docs/cpp/c-cpp-properties-schema-reference.md). +- Review the [Overview of the C++ extension](/docs/languages/cpp.md). diff --git a/docs/cpp/faq-cpp.md b/docs/cpp/faq-cpp.md index ad97660887..cc80484fd4 100644 --- a/docs/cpp/faq-cpp.md +++ b/docs/cpp/faq-cpp.md @@ -1,5 +1,5 @@ --- -Order: 14 +Order: 15 Area: cpp TOCTitle: FAQ ContentId: 652c9cec-b8fa-4597-a894-f2ea9a095c31 diff --git a/docs/cpp/images/intellisense/compiler-quick-pick.png b/docs/cpp/images/intellisense/compiler-quick-pick.png new file mode 100644 index 0000000000..0dfe89920b --- /dev/null +++ b/docs/cpp/images/intellisense/compiler-quick-pick.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1fa610886a938cb17965902107e3e069cd9d4ed55584c06cbafc603518008aec +size 133784 diff --git a/docs/cpp/images/intellisense/configure-intellisense-indicator.png b/docs/cpp/images/intellisense/configure-intellisense-indicator.png new file mode 100644 index 0000000000..a0497bc55e --- /dev/null +++ b/docs/cpp/images/intellisense/configure-intellisense-indicator.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86c07b1453641882aeb7ad9061a47e416af39d45edab6ec8eb6f2eaf3ca4824c +size 25686 diff --git a/docs/cpp/images/intellisense/language-status-bar.png b/docs/cpp/images/intellisense/language-status-bar.png new file mode 100644 index 0000000000..6fcb82ae93 --- /dev/null +++ b/docs/cpp/images/intellisense/language-status-bar.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cf30f0282fb5c3d08fdaad063c0b5b6f6038c7ebea1c3c8e83d73f26c8f81516 +size 248596 From 5e8f77f3fa1dfc8d2dbffae5cc1a3d510c617fe9 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Tue, 29 Aug 2023 17:16:52 -0700 Subject: [PATCH 2/8] Update schema, add other config option support --- docs/cpp/c-cpp-properties-schema-reference.md | 32 +++++++++++++----- docs/cpp/configure-intellisense.md | 33 +++++++++++-------- 2 files changed, 42 insertions(+), 23 deletions(-) diff --git a/docs/cpp/c-cpp-properties-schema-reference.md b/docs/cpp/c-cpp-properties-schema-reference.md index ee78ace653..5131d0c58b 100644 --- a/docs/cpp/c-cpp-properties-schema-reference.md +++ b/docs/cpp/c-cpp-properties-schema-reference.md @@ -11,7 +11,7 @@ MetaDescription: Schema reference for C++ project settings in Visual Studio Code This article explains the scheme for the c_cpp_properties.json settings file. -For more information about changing these settings, see [Customizing Default Settings](/docs/cpp/customize-default-settings-cpp.md) and [Configure IntelliSense](/docs/cpp/configure-intellisense.md). +Looking to get started with configuring your project? See [Configure Intellisense](/docs/cpp/configure-intellisense.md).For more information about changing these settings, see [Customizing Default Settings](/docs/cpp/customize-default-settings-cpp.md). ## Example @@ -33,8 +33,8 @@ For more information about changing these settings, see [Customizing Default Set "defines": [ "FOO", "BAR=100" ], "forcedInclude": [ "${workspaceFolder}/include/config.h" ], "compilerPath": "/usr/bin/clang", - "cStandard": "c11", - "cppStandard": "c++17", + "cStandard": "c23", + "cppStandard": "c++23", "compileCommands": "/path/to/compile_commands.json", "browse": { "path": [ "${workspaceFolder}" ], @@ -58,10 +58,13 @@ For more information about changing these settings, see [Customizing Default Set - `version` We recommend you don't edit this field. It tracks the current version of the `c_cpp_properties.json` file so that the extension knows what properties and settings should be present and how to upgrade this file to the latest version. +- `enableConfigurationSquiggles` + Set to `true` to report errors detected in `c_cpp_properties.json` file to the C/C++ Extension. + ## Configuration properties - `name` - A friendly name that identifies a configuration. `Linux`, `Mac`, and `Win32` are special identifiers for configurations that will be autoselected on those platforms. The status bar in VS Code will show you which configuration is active. You can also click on the label in the status bar to change the active configuration. + A friendly name that identifies a configuration. `Linux`, `Mac`, and `Win32` are special identifiers for configurations that will be autoselected on those platforms. The status bar in VS Code will show you which configuration is active. You can also select on the label in the status bar to change the active configuration. - `compilerPath` (optional) The full path to the compiler you use to build your project, for example `/usr/bin/gcc`, to enable more accurate IntelliSense. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense. @@ -69,7 +72,7 @@ For more information about changing these settings, see [Customizing Default Set Putting `"compilerPath": ""` (empty string) will skip querying a compiler. This is useful if a specified compiler doesn't support the arguments that are used for the query, as the extension will default back to any compiler it can find (like Visual C). Leaving out the `compilerPath` property does not skip the query. - `compilerArgs` (optional) - Compiler arguments to modify the includes or defines used, for example `-nostdinc++`, `-m32`, etc. + Compiler arguments to modify the includes or defines used, for example `-nostdinc++`, `-m32`, etc. Arguments that take additional space-delimited arguments should be entered as separate arguments in the array, for example, for `--sysroot ` use `\"--sysroot\", \"\"`. - `intelliSenseMode` The IntelliSense mode to use that maps to an architecture-specific variant of MSVC, gcc, or Clang. If not set or if set to `${default}`, the extension will choose the default for that platform. @@ -79,6 +82,8 @@ For more information about changing these settings, see [Customizing Default Set - Linux: `gcc-x64` - macOS: `clang-x64` + IntelliSense modes that only specify `-` variants (for example, `gcc-x64`) are legacy modes and are automatically converted to the `--` variants based on the host platform. + - `includePath` An include path is a folder that contains header files (such as `#include "myHeaderFile.h"`) that are included in a source file. Specify a list of paths for the IntelliSense engine to use while searching for included header files. Searching on these paths is not recursive. Specify `**` to indicate recursive search. For example, `${workspaceFolder}/**` will search through all subdirectories while `${workspaceFolder}` will not. If on Windows with Visual Studio installed, or if a compiler is specified in the `compilerPath` setting, it is not necessary to list the system include paths in this list. @@ -86,10 +91,10 @@ For more information about changing these settings, see [Customizing Default Set A list of preprocessor definitions for the IntelliSense engine to use while parsing files. Optionally, use `=` to set a value, for example `VERSION=1`. - `cStandard` - The version of the C language standard to use for IntelliSense. + The version of the C language standard to use for IntelliSense. For example, `c17`, `gnu23`, or `${default}`. Note that GNU standards are only used to query the set compiler to get GNU defines, and IntelliSense will emulate the equivalent C standard version. - `cppStandard` - The version of the C++ language standard to use for IntelliSense. + The version of the C++ language standard to use for IntelliSense. For example, `c++20`, `gnu++23`, or `${default}`. Note: GNU standards are only used to query the set compiler to get GNU defines, and IntelliSense will emulate the equivalent C++ standard version. - `configurationProvider` The ID of a VS Code extension that can provide IntelliSense configuration information for source files. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the CMake Tools extension. @@ -106,17 +111,26 @@ For more information about changing these settings, see [Customizing Default Set A list of files that should be included before any other characters in the source file are processed. Files are included in the order listed. - `compileCommands` (optional) - The full path to the `compile_commands.json` file for the workspace. The include paths and defines discovered in this file will be used instead of the values set for `includePath` and `defines` settings. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the `includePath` and `defines` settings instead. + The full path to the `compile_commands.json` file for the workspace. The include paths and defines discovered in this file will take precedence over your other settings in `c_cpp_properties.json`, such as `includePath` and `defines`. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the `includePath` and `defines` settings instead. For more information about the file format, see the [Clang documentation](https://clang.llvm.org/docs/JSONCompilationDatabase.html). Some build systems, such as CMake, [simplify generating this file](https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). +- `dotconfig` + A path to a .config file created by the Kconfig system. The Kconfig system generates a file with all the defines needed to build a project. Examples of projects that use the Kconfig system are the Linux Kernel and NuttX RTOS. + +- `mergeConfigurations` + Set to `true` to merge include paths, defines, and forced includes with those from a configuration provider. + +- `customConfigurationVariables` + Custom variables that can be queried through the command `${cpptools:activeConfigCustomVariable}` to use for the input variables in `launch.json` or `tasks.json`. + - `browse` The set of properties used when `"C_Cpp.intelliSenseEngine"` is set to `"Tag Parser"` (also referred to as "fuzzy" IntelliSense, or the "browse" engine). These properties are also used by the **Go to Definition/Declaration** features, or when the "default" IntelliSense engine is unable to resolve the `#includes` in your source files. ### Browse properties - `path` - A list of paths for the Tag Parser to search for headers included by your source files. If omitted, `includePath` will be used as the `path`. Searching on these paths is recursive by default. Specify `*` to indicate non-recursive search. For example: `${workspaceFolder}` will search through all subdirectories while `${workspaceFolder}/*` will not. + A list of paths for the Tag Parser to search for headers included by your source files. If omitted, `includePath` will be used as the `path`. Searching on these paths is recursive by default. Specify `*` to indicate nonrecursive search. For example: `${workspaceFolder}` will search through all subdirectories while `${workspaceFolder}/*` will not. - `limitSymbolsToIncludedHeaders` When true, the Tag Parser will only parse code files that have been directly or indirectly included by a source file in `${workspaceFolder}`. When false, the Tag Parser will parse all code files found in the paths specified in the `browse.path` list. diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 82622911ff..9627bce6f9 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -18,7 +18,7 @@ IntelliSense is powered by a language service, which provides C++ specific langu 1. compile_commands.json file 1. Another extension (for example, the [Makefile](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake extension](/docs/cpp/CMake-linux.md)). -## When is a compiler automatically configured? +## When is IntelliSense automatically configured? The C/C++ Extension, in most occasions, configures IntelliSense automatically for you. Common compiler paths in world writeable locations are queried on your machine, and if a compiler is available, are configured. If a compiler in a non-world writeable location is determined, a notification is displayed asking to configure this compiler. When approving compilers for IntelliSense, ensure that the compiler path is correct. Common compilers in their default world writeable locations that are automatically configured include the clang compiler, GCC, MinGW, and MSVC. If a compile_commands.json file or another extension that provides a configuration is found in your workspace, the extension will also automatically use these options to configure IntelliSense. @@ -32,7 +32,7 @@ There are multiple options to determine your IntelliSense status: ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) -To configure, simply select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). +To configure, select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). ### Option 2: Check the language status bar @@ -62,25 +62,30 @@ Open the quick pick by entering **Select IntelliSense Configuration** in the Com Select one of the options available. You can return to the Configuration Quick Pick at any point to change which option is being configured for IntelliSense. -If no options are available in the quick pick, there are multiple options to install the right compiler. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the clang or GCC compiler installed on your machine. +If no options are available in the quick pick, there are multiple options to help you install a compiler which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the clang or GCC compiler installed on your machine. -### Option 2. Edit the `c_cpp_properties.json` file +### Option 2. Edit your IntelliSense configurations -You can edit the `c_cpp_properties.json` file directly to add your compiler or configuration option. Open the file by selecting **C/C++: Edit Configurations (JSON)** from the Command Palette (`kb(workbench.action.showCommands)`). Set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. +Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). -If you prefer to access the `c_cpp_properties.json` file directly, use the "C/C++ Edit Configurations (JSON)" command from the Command Palette (`kb(workbench.action.showCommands)`) and updated the "compiler path" variable in the same manner. +For configuring a compile_commands.json file, enter the full path of the compile_commands.json file into the Compile commands field. For example, if your compile_commands.json file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. -Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to "gcc-x64" or "clang-x64" to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the CMake Tools extension. -## Understanding the `c_cpp_properties.json` file +For configuring a compiler, set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to `gcc-x64` or `clang-x64` to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. -The `c_cpp_properties.json` file is used to configure IntelliSense for the C/C++ Extension. It's located in the `.vscode` folder of your workspace. The C/C++ Extension automatically creates this file for you if you have a compiler installed in a world writeable location. If you don't have a compiler installed, you can create this file manually. The file contains fields such as: +### Option 3. Edit the `c_cpp_properties.json` file directly + +The `c_cpp_properties.json` file is used to configure IntelliSense for the C/C++ Extension. It's located in the `.vscode` folder of your workspace. The edit configuration view in option 2 is an interface for the `c_cpp_properties.json` file. The C/C++ Extension automatically creates this file for you if you have a compiler installed in a world writeable location. If you don't have a compiler installed, you can create this file manually. + +You can edit the `c_cpp_properties.json` file directly to add or update your configuration choices. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`) and add the relevant settings. For compile_commands.json as a configuration, use the `compileCommands` variable and for using another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. + +Make sure you have defined the following settings if you are writing to your `c_cpp_properties.json` file: -- Compiler path: The full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. - IntelliSense mode: The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. -- Include path: You only need to modify the **Include path** if your program includes header files that aren't in your workspace or that aren't in the standard library path.The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually: +- Include path: You only need to modify the **Include path** if your program includes header files that aren't in your workspace or that aren't in the standard library path.The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. -For all of the fields in the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). Here's a sample `c_cpp_configuration.json` file on a Windows machine using the default install path for minGW: @@ -98,8 +103,8 @@ Here's a sample `c_cpp_configuration.json` file on a Windows machine using the d "_UNICODE" ], "windowsSdkVersion": "10.0.22621.0", - "cStandard": "c17", - "cppStandard": "c++17", + "cStandard": "c23", + "cppStandard": "c++23", "intelliSenseMode": "${default}", "compilerPath": "C:/msys64/mingw64/bin/gcc.exe" } From 058ad14d719fe65c25fdbf9172d46d4ded3c6094 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Fri, 1 Sep 2023 16:35:19 -0700 Subject: [PATCH 3/8] Add PR feedback --- docs/cpp/c-cpp-properties-schema-reference.md | 2 +- docs/cpp/configure-intellisense.md | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/cpp/c-cpp-properties-schema-reference.md b/docs/cpp/c-cpp-properties-schema-reference.md index 5131d0c58b..f068fad0d0 100644 --- a/docs/cpp/c-cpp-properties-schema-reference.md +++ b/docs/cpp/c-cpp-properties-schema-reference.md @@ -64,7 +64,7 @@ Looking to get started with configuring your project? See [Configure Intellisens ## Configuration properties - `name` - A friendly name that identifies a configuration. `Linux`, `Mac`, and `Win32` are special identifiers for configurations that will be autoselected on those platforms. The status bar in VS Code will show you which configuration is active. You can also select on the label in the status bar to change the active configuration. + A friendly name that identifies a configuration. `Linux`, `Mac`, and `Win32` are special identifiers for configurations that will be autoselected on those platforms. The status bar in VS Code will show you which configuration is active. You can also select the label in the status bar to change the active configuration. - `compilerPath` (optional) The full path to the compiler you use to build your project, for example `/usr/bin/gcc`, to enable more accurate IntelliSense. The extension will query the compiler to determine the system include paths and default defines to use for IntelliSense. diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 9627bce6f9..ff1a33a6c1 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -2,25 +2,25 @@ Order: 13 Area: cpp TOCTitle: Configure IntelliSense -ContentId: 381b7ce1-5766-49b0-ad26-f9eedae70e63 -PageTitle: Configure IntelliSense +ContentId: bf494c65-12b4-4506-ab6c-1fad76d7ccf1 +PageTitle: Configure C/C++ IntelliSense DateApproved: 8/23/2023 MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extension --- -# Configuring IntelliSense +# Configure C/C++ IntelliSense This article is about configuring the C/C++ extension to provide proper [IntelliSense](/docs/editor/intellisense.md). IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. IntelliSense is powered by a language service, which provides C++ specific language completions in your code. For the extension to provide correct IntelliSense suggestions, you need to configure the C/C++ extension. There are three types of sources that can be used for configuration: -1. A C/C++ compiler -1. compile_commands.json file -1. Another extension (for example, the [Makefile](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake extension](/docs/cpp/CMake-linux.md)). +- A C/C++ compiler +- `compile_commands.json` file +- Another extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake extension](/docs/cpp/CMake-linux.md)). ## When is IntelliSense automatically configured? -The C/C++ Extension, in most occasions, configures IntelliSense automatically for you. Common compiler paths in world writeable locations are queried on your machine, and if a compiler is available, are configured. If a compiler in a non-world writeable location is determined, a notification is displayed asking to configure this compiler. When approving compilers for IntelliSense, ensure that the compiler path is correct. Common compilers in their default world writeable locations that are automatically configured include the clang compiler, GCC, MinGW, and MSVC. If a compile_commands.json file or another extension that provides a configuration is found in your workspace, the extension will also automatically use these options to configure IntelliSense. +The C/C++ Extension, in most occasions, configures IntelliSense automatically for you. Common compiler paths in world writeable locations are queried on your machine, and if a compiler is available, are configured. If a compiler in a non-world writeable location is determined, a notification is displayed asking to configure this compiler. When approving compilers for IntelliSense, ensure that the compiler path is correct. Common compilers in their default world writeable locations that are automatically configured include the clang compiler, GCC, MinGW, and MSVC. If a `compile_commands.json` file or another extension that provides a configuration is found in your workspace, the extension will also automatically use these options to configure IntelliSense. ## How to check whether IntelliSense is configured @@ -32,7 +32,7 @@ There are multiple options to determine your IntelliSense status: ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) -To configure, select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). +To configure, select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). ### Option 2: Check the language status bar @@ -40,7 +40,7 @@ To invoke the language status bar, open a C++ file. Note that the status bar now - "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and will automatically activate if you interact with the editor, for example, by writing code. - "IntelliSense: Updating" = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code -- "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide your with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense#_selecting-a-compiler-for-IntelliSense.md) as explained below. +- "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. ![language-status-bar](images/intellisense/language-status-bar.png) @@ -62,15 +62,15 @@ Open the quick pick by entering **Select IntelliSense Configuration** in the Com Select one of the options available. You can return to the Configuration Quick Pick at any point to change which option is being configured for IntelliSense. -If no options are available in the quick pick, there are multiple options to help you install a compiler which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the clang or GCC compiler installed on your machine. +If no options are available in the quick pick, there are multiple options to help you install a compiler which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. ### Option 2. Edit your IntelliSense configurations Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). -For configuring a compile_commands.json file, enter the full path of the compile_commands.json file into the Compile commands field. For example, if your compile_commands.json file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. +For configuring a `compile_commands.json` file, enter the full path of the `compile_commands.json` file into the Compile commands field. For example, if your `compile_commands.json` file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. -For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the CMake Tools extension. +For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). For configuring a compiler, set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to `gcc-x64` or `clang-x64` to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. @@ -78,7 +78,7 @@ For configuring a compiler, set the "Compiler path" field to the full path of th The `c_cpp_properties.json` file is used to configure IntelliSense for the C/C++ Extension. It's located in the `.vscode` folder of your workspace. The edit configuration view in option 2 is an interface for the `c_cpp_properties.json` file. The C/C++ Extension automatically creates this file for you if you have a compiler installed in a world writeable location. If you don't have a compiler installed, you can create this file manually. -You can edit the `c_cpp_properties.json` file directly to add or update your configuration choices. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`) and add the relevant settings. For compile_commands.json as a configuration, use the `compileCommands` variable and for using another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. +You can edit the `c_cpp_properties.json` file directly to add or update your configuration choices. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`) and add the relevant settings. For `compile_commands.json` as a configuration, use the `compileCommands` variable and for using another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Make sure you have defined the following settings if you are writing to your `c_cpp_properties.json` file: From 939b3a495761f4e1ae2a3bcce3017c476761b0cc Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Tue, 17 Oct 2023 14:12:22 -0700 Subject: [PATCH 4/8] Update automatic config process --- docs/cpp/configure-intellisense.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index ff1a33a6c1..947c2ecff6 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -10,9 +10,9 @@ MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extensio --- # Configure C/C++ IntelliSense -This article is about configuring the C/C++ extension to provide proper [IntelliSense](/docs/editor/intellisense.md). IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. +This article is about configuring the C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. -IntelliSense is powered by a language service, which provides C++ specific language completions in your code. For the extension to provide correct IntelliSense suggestions, you need to configure the C/C++ extension. There are three types of sources that can be used for configuration: +There are three types of sources that can be used for configuration: - A C/C++ compiler - `compile_commands.json` file @@ -20,7 +20,9 @@ IntelliSense is powered by a language service, which provides C++ specific langu ## When is IntelliSense automatically configured? -The C/C++ Extension, in most occasions, configures IntelliSense automatically for you. Common compiler paths in world writeable locations are queried on your machine, and if a compiler is available, are configured. If a compiler in a non-world writeable location is determined, a notification is displayed asking to configure this compiler. When approving compilers for IntelliSense, ensure that the compiler path is correct. Common compilers in their default world writeable locations that are automatically configured include the clang compiler, GCC, MinGW, and MSVC. If a `compile_commands.json` file or another extension that provides a configuration is found in your workspace, the extension will also automatically use these options to configure IntelliSense. +The C++ Extension, in most occasions, configures IntelliSense automatically for you. For example, if you have previously selected a compiler for IntelliSense, that compiler will be set as your default compiler. Your default compiler is chosen to configure IntelliSense. Otherwise, if you have not previously selected a compiler, common compiler paths are queried by the C++ Extension. If a compiler is found in a world writeable location, that compiler is configured for IntelliSense. This applies to many common compilers in their default locations such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If a compiler is not in a world writeable location, a notification is displayed asking to configure this compiler. When you approve a compiler for IntelliSense, double check that the compiler path stated is as expected. + +If another extension is able to provide the configuration for IntelliSense, this configuration is set as your configuration provider in the C++ Extension. Configuration providers are automatically selected to configure IntelliSense. If the extension's configuration can not be configured, the C++ Extension will fall back to the base configuration provided in your `c_cpp_properties.json` file. This includes your default compiler or any compilers found when querying through the process mentioned above. ## How to check whether IntelliSense is configured @@ -36,9 +38,9 @@ To configure, select the status bar indicator, which navigates you to the [confi ### Option 2: Check the language status bar -To invoke the language status bar, open a C++ file. Note that the status bar now shows the text "{} C++". Hover over the "{}" symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: +To invoke the language status bar, open a C++ file. Note that the status bar shows the text "{} C++". Hover over the "{}" symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: -- "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and will automatically activate if you interact with the editor, for example, by writing code. +- "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. - "IntelliSense: Updating" = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code - "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. @@ -52,7 +54,7 @@ All configuration settings are stored in your project's `c_cpp_properties.json` ## How to configure IntelliSense -If you have determined that IntelliSense isn't configured, you have multiple options to configure: +Before you configure, understand that IntelliSense configuration is always stored in the `c_cpp_properties.json` file, which is automatically created in your workspace. All three of the following options are different ways of editing the `c_cpp_properties.json` file: ### Option 1. Select a configuration option through the configuration Quick Pick @@ -60,13 +62,13 @@ Open the quick pick by entering **Select IntelliSense Configuration** in the Com ![Compiler Quick Pick](images/intellisense/compiler-quick-pick.png) -Select one of the options available. You can return to the Configuration Quick Pick at any point to change which option is being configured for IntelliSense. +Select one of the options available. If you select a compiler, this compiler will also be set as your default compiler. You can return to the Configuration Quick Pick at any point to change which option chosen to configure IntelliSense. -If no options are available in the quick pick, there are multiple options to help you install a compiler which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. +If no options are available in the quick pick, there are multiple options to help you install a compiler, which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. -### Option 2. Edit your IntelliSense configurations +### Option 2. Edit your IntelliSense configurations UI -Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). +Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This is an easy to navigate interface of the `c_cpp_properties.json` file. For configuring a `compile_commands.json` file, enter the full path of the `compile_commands.json` file into the Compile commands field. For example, if your `compile_commands.json` file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. @@ -76,9 +78,9 @@ For configuring a compiler, set the "Compiler path" field to the full path of th ### Option 3. Edit the `c_cpp_properties.json` file directly -The `c_cpp_properties.json` file is used to configure IntelliSense for the C/C++ Extension. It's located in the `.vscode` folder of your workspace. The edit configuration view in option 2 is an interface for the `c_cpp_properties.json` file. The C/C++ Extension automatically creates this file for you if you have a compiler installed in a world writeable location. If you don't have a compiler installed, you can create this file manually. +You can edit the `c_cpp_properties.json` file directly to customize your configuration. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`), then the `c_cpp_properties.json` file is found in the `.vscode` folder of your workspace. -You can edit the `c_cpp_properties.json` file directly to add or update your configuration choices. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`) and add the relevant settings. For `compile_commands.json` as a configuration, use the `compileCommands` variable and for using another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. +To select `compile_commands.json` as a configuration, add or update the `compileCommands` variable. For configuring another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Make sure you have defined the following settings if you are writing to your `c_cpp_properties.json` file: From 52aa45dad4023f658b11c2f53161e8d7c604c949 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Tue, 17 Oct 2023 16:21:55 -0700 Subject: [PATCH 5/8] colen review --- docs/cpp/configure-intellisense.md | 60 +++++++++++++----------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 947c2ecff6..96282d7dc5 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -4,37 +4,30 @@ Area: cpp TOCTitle: Configure IntelliSense ContentId: bf494c65-12b4-4506-ab6c-1fad76d7ccf1 PageTitle: Configure C/C++ IntelliSense -DateApproved: 8/23/2023 +DateApproved: 10/1/2023 MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extension - --- # Configure C/C++ IntelliSense -This article is about configuring the C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. - -There are three types of sources that can be used for configuration: +This article is about configuring the C/C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. -- A C/C++ compiler -- `compile_commands.json` file -- Another extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake extension](/docs/cpp/CMake-linux.md)). +C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For more advanced project level configurations, reference the section [Advanced C++ IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Advanced-C++-IntelliSense-Configuration). ## When is IntelliSense automatically configured? -The C++ Extension, in most occasions, configures IntelliSense automatically for you. For example, if you have previously selected a compiler for IntelliSense, that compiler will be set as your default compiler. Your default compiler is chosen to configure IntelliSense. Otherwise, if you have not previously selected a compiler, common compiler paths are queried by the C++ Extension. If a compiler is found in a world writeable location, that compiler is configured for IntelliSense. This applies to many common compilers in their default locations such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If a compiler is not in a world writeable location, a notification is displayed asking to configure this compiler. When you approve a compiler for IntelliSense, double check that the compiler path stated is as expected. - -If another extension is able to provide the configuration for IntelliSense, this configuration is set as your configuration provider in the C++ Extension. Configuration providers are automatically selected to configure IntelliSense. If the extension's configuration can not be configured, the C++ Extension will fall back to the base configuration provided in your `c_cpp_properties.json` file. This includes your default compiler or any compilers found when querying through the process mentioned above. + A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will query common compiler paths on your machine such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are found, they are automatically configured for IntelliSense. If any other C/C++ compiler is found, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. ## How to check whether IntelliSense is configured -There are multiple options to determine your IntelliSense status: +If you have a compiler installed, there are multiple options to determine if it has been configured for IntelliSense: ### Option 1: Check for a status bar indicator - If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating "Configure IntelliSense". +If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating "Configure IntelliSense". ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) -To configure, select the status bar indicator, which navigates you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). +To configure, select the status bar indicator, which navigates you to the [configuration quickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). ### Option 2: Check the language status bar @@ -43,50 +36,38 @@ To invoke the language status bar, open a C++ file. Note that the status bar sho - "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. - "IntelliSense: Updating" = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code - "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. - ![language-status-bar](images/intellisense/language-status-bar.png) ### Option 3: Check the `c_cpp_properties.json` file -All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the "IntelliSense mode" to understand your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). - +All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the "IntelliSense mode" to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). ![Command Palette](images/cpp/command-palette.png) ## How to configure IntelliSense -Before you configure, understand that IntelliSense configuration is always stored in the `c_cpp_properties.json` file, which is automatically created in your workspace. All three of the following options are different ways of editing the `c_cpp_properties.json` file: +Before you configure, understand that IntelliSense configuration is stored in the `c_cpp_properties.json` file, which is automatically created in your workspace. All three of the following options are different ways of editing the `c_cpp_properties.json` file: ### Option 1. Select a configuration option through the configuration Quick Pick Open the quick pick by entering **Select IntelliSense Configuration** in the Command Palette (`kb(workbench.action.showCommands)`), which shows you a dropdown with all of the configuration options found by the C/C++ Extension on your machine. - ![Compiler Quick Pick](images/intellisense/compiler-quick-pick.png) - Select one of the options available. If you select a compiler, this compiler will also be set as your default compiler. You can return to the Configuration Quick Pick at any point to change which option chosen to configure IntelliSense. - -If no options are available in the quick pick, there are multiple options to help you install a compiler, which you can use for IntelliSense. On a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. +If no options are available in the quick pick, no compiler could be identified in your system. You can browse your machine manually or install a C/C++ compiler. To install on a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. ### Option 2. Edit your IntelliSense configurations UI Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This is an easy to navigate interface of the `c_cpp_properties.json` file. - -For configuring a `compile_commands.json` file, enter the full path of the `compile_commands.json` file into the Compile commands field. For example, if your `compile_commands.json` file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. - -For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). - -For configuring a compiler, set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to `gcc-x64` or `clang-x64` to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. +Set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to `gcc-x64` or `clang-x64` to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. ### Option 3. Edit the `c_cpp_properties.json` file directly You can edit the `c_cpp_properties.json` file directly to customize your configuration. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`), then the `c_cpp_properties.json` file is found in the `.vscode` folder of your workspace. - -To select `compile_commands.json` as a configuration, add or update the `compileCommands` variable. For configuring another extension, use the `configurationProvider` variable. To add a compiler, use the `compilerPath` variable. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. - + Use the `compilerPath` variable to add a compiler. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Make sure you have defined the following settings if you are writing to your `c_cpp_properties.json` file: - IntelliSense mode: The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. - Include path: You only need to modify the **Include path** if your program includes header files that aren't in your workspace or that aren't in the standard library path.The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. - +- For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). Here's a sample `c_cpp_configuration.json` file on a Windows machine using the default install path for minGW: @@ -105,8 +86,8 @@ Here's a sample `c_cpp_configuration.json` file on a Windows machine using the d "_UNICODE" ], "windowsSdkVersion": "10.0.22621.0", - "cStandard": "c23", - "cppStandard": "c++23", + "cStandard": "c17", + "cppStandard": "c++17", "intelliSenseMode": "${default}", "compilerPath": "C:/msys64/mingw64/bin/gcc.exe" } @@ -115,6 +96,17 @@ Here's a sample `c_cpp_configuration.json` file on a Windows machine using the d } ``` +## Advanced-C++-IntelliSense-Configuration + +- `compile_commands.json` file +- Another extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). +- +- If another extension is able to provide the configuration for IntelliSense, this configuration is set as your configuration provider in the C++ Extension. Configuration providers are automatically selected to configure IntelliSense. If the extension's configuration can not be configured, the C++ Extension will fall back to the base configuration provided in your `c_cpp_properties.json` file. This includes your default compiler or any compilers found when querying through the process mentioned above. +- +- For configuring a `compile_commands.json` file, enter the full path of the `compile_commands.json` file into the Compile commands field. For example, if your `compile_commands.json` file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. +For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). +To select `compile_commands.json` as a configuration, add or update the `compileCommands` variable. For configuring another extension, use the `configurationProvider` variable. + ## Next steps - For more information about IntelliSense configuration, see [Customizing default settings](/docs/cpp/customize-default-settings-cpp.md). From ef91b4083758309eadcfd990c0ef25805e7963f3 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Thu, 26 Oct 2023 16:16:38 -0700 Subject: [PATCH 6/8] Re organized sections, added samples --- docs/cpp/c-cpp-properties-schema-reference.md | 114 ++++++++++++--- docs/cpp/configure-intellisense.md | 136 +++++++++++++----- 2 files changed, 193 insertions(+), 57 deletions(-) diff --git a/docs/cpp/c-cpp-properties-schema-reference.md b/docs/cpp/c-cpp-properties-schema-reference.md index f068fad0d0..cbedcd9f35 100644 --- a/docs/cpp/c-cpp-properties-schema-reference.md +++ b/docs/cpp/c-cpp-properties-schema-reference.md @@ -13,37 +13,106 @@ This article explains the scheme for the c_cpp_properties.json settings file. Looking to get started with configuring your project? See [Configure Intellisense](/docs/cpp/configure-intellisense.md).For more information about changing these settings, see [Customizing Default Settings](/docs/cpp/customize-default-settings-cpp.md). -## Example +## Example of Variables + +Note, this is an example of all fields. You do not need to specify all fields in your `c_cpp_properties.json` file. The extension will automatically fill in any missing fields with default values. ```json { - "env" : { - "myDefaultIncludePath": [ - "${workspaceFolder}", - "${workspaceFolder}/include" + "env": { + "myIncludePath": [ + "${workspaceFolder}/include", + "${workspaceFolder}/src" ], - "myCompilerPath": "/usr/local/bin/gcc-7" + "myDefines": [ + "DEBUG", + "MY_FEATURE=1" + ] }, "configurations": [ + { + "name": "Linux", + "compilerPath": "/usr/bin/gcc", + "compilerArgs": [ + "-m32" + ], + "intelliSenseMode": "linux-gcc-x86", + "includePath": [ + "${myIncludePath}", + "/usr/include" + ], + "defines": [ + "${myDefines}" + ], + "cStandard": "gnu11", + "cppStandard": "gnu++14", + "configurationProvider": "ms-vscode.cmake-tools", + "forcedInclude": [ + "${workspaceFolder}/common.h" + ], + "compileCommands": "${workspaceFolder}/build/compile_commands.json", + "dotconfig": "${workspaceFolder}/.config", + "mergeConfigurations": true, + "customConfigurationVariables": { + "myVar": "myvalue" + }, + "browse": { + "path": [ + "${myIncludePath}", + "/usr/include", + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db" + } + }, { "name": "Mac", - "intelliSenseMode": "clang-x64", - "includePath": [ "${myDefaultIncludePath}", "/another/path" ], - "macFrameworkPath": [ "/System/Library/Frameworks" ], - "defines": [ "FOO", "BAR=100" ], - "forcedInclude": [ "${workspaceFolder}/include/config.h" ], "compilerPath": "/usr/bin/clang", - "cStandard": "c23", - "cppStandard": "c++23", - "compileCommands": "/path/to/compile_commands.json", + "intelliSenseMode": "macos-clang-x64", + "includePath": [ + "${myIncludePath}" + ], + "defines": [ + "${myDefines}" + ], + "cStandard": "c11", + "cppStandard": "c++17", + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ], "browse": { - "path": [ "${workspaceFolder}" ], - "limitSymbolsToIncludedHeaders": true, - "databaseFilename": "" + "path": [ + "${myIncludePath}", + "${workspaceFolder}" + ] + } + }, + { + "name": "Win32", + "compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe", + "intelliSenseMode": "windows-msvc-x64", + "includePath": [ + "${myIncludePath}" + ], + "defines": [ + "${myDefines}", + "_WINDOWS" + ], + "cStandard": "c17", + "cppStandard": "c++20", + "windowsSdkVersion": "10.0.19041.0", + "browse": { + "path": [ + "${myIncludePath}", + "${workspaceFolder}" + ] } } ], - "version": 4 + "version": 4, + "enableConfigurationSquiggles": true } ``` @@ -78,9 +147,9 @@ Looking to get started with configuring your project? See [Configure Intellisens The IntelliSense mode to use that maps to an architecture-specific variant of MSVC, gcc, or Clang. If not set or if set to `${default}`, the extension will choose the default for that platform. Platform defaults: - - Windows: `msvc-x64` - - Linux: `gcc-x64` - - macOS: `clang-x64` + - Windows: `windows-msvc-x64` + - Linux: `linux-gcc-x64` + - macOS: `macos-clang-x64` IntelliSense modes that only specify `-` variants (for example, `gcc-x64`) are legacy modes and are automatically converted to the `--` variants based on the host platform. @@ -111,8 +180,7 @@ Looking to get started with configuring your project? See [Configure Intellisens A list of files that should be included before any other characters in the source file are processed. Files are included in the order listed. - `compileCommands` (optional) - The full path to the `compile_commands.json` file for the workspace. The include paths and defines discovered in this file will take precedence over your other settings in `c_cpp_properties.json`, such as `includePath` and `defines`. If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, then a warning message will appear and the extension will use the `includePath` and `defines` settings instead. - + The full path to the `compile_commands.json` file for the workspace. If there is a matching entry in `compile_commands.json` for a file open in the editor, that command line will be used to configure IntelliSense for that file, instead of the other fields of `c_cpp_properties.json`. For more information about the file format, see the [Clang documentation](https://clang.llvm.org/docs/JSONCompilationDatabase.html). Some build systems, such as CMake, [simplify generating this file](https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html). - `dotconfig` diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 96282d7dc5..9508519c78 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -4,18 +4,18 @@ Area: cpp TOCTitle: Configure IntelliSense ContentId: bf494c65-12b4-4506-ab6c-1fad76d7ccf1 PageTitle: Configure C/C++ IntelliSense -DateApproved: 10/1/2023 +DateApproved: 10/26/2023 MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extension --- # Configure C/C++ IntelliSense This article is about configuring the C/C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. -C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For more advanced project level configurations, reference the section [Advanced C++ IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Advanced-C++-IntelliSense-Configuration). +C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For more advanced project level configurations, reference the section [Project level IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Project-level-IntelliSense-Configuration). ## When is IntelliSense automatically configured? - A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will query common compiler paths on your machine such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are found, they are automatically configured for IntelliSense. If any other C/C++ compiler is found, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. + A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will scan common paths on your machine for compilers such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are identified and in a secure location, they are automatically configured for IntelliSense. Otherwise, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. ## How to check whether IntelliSense is configured @@ -23,55 +23,59 @@ If you have a compiler installed, there are multiple options to determine if it ### Option 1: Check for a status bar indicator -If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating "Configure IntelliSense". +If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating **Configure IntelliSense**. ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) -To configure, select the status bar indicator, which navigates you to the [configuration quickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The status bar indicator also is shown if you have provided a configuration for IntelliSense, but the C/C++ Extension is reverting to the base configuration provided in your `c_cpp_properties.json` file. In this case, open the `c_cpp_properties.json` file (Select **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`)). +To configure, select the status bar indicator, which navigates you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The quick pick can help you select or install a C/C++ compiler. ### Option 2: Check the language status bar -To invoke the language status bar, open a C++ file. Note that the status bar shows the text "{} C++". Hover over the "{}" symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: +To invoke the language status bar, open a C++ file. Note that the status bar shows the text **{} C++**. Hover over the **{}** symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: -- "IntelliSense: Ready" = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. -- "IntelliSense: Updating" = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code -- "IntelliSense: Not configured" = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quickpickpick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. -![language-status-bar](images/intellisense/language-status-bar.png) +- **IntelliSense: Ready** = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. +- **IntelliSense: Updating** = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code. +- **IntelliSense: Not configured** = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. + + ![language-status-bar](images/intellisense/language-status-bar.png) ### Option 3: Check the `c_cpp_properties.json` file -All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the "IntelliSense mode" to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the `IntelliSense mode` to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). + ![Command Palette](images/cpp/command-palette.png) ## How to configure IntelliSense -Before you configure, understand that IntelliSense configuration is stored in the `c_cpp_properties.json` file, which is automatically created in your workspace. All three of the following options are different ways of editing the `c_cpp_properties.json` file: +IntelliSense configuration is stored in the `c_cpp_properties.json` file, which is automatically created in your workspace. All three of the following options are different ways of editing the `c_cpp_properties.json` file: -### Option 1. Select a configuration option through the configuration Quick Pick +### Option 1. Select a configuration option through the configuration quick pick Open the quick pick by entering **Select IntelliSense Configuration** in the Command Palette (`kb(workbench.action.showCommands)`), which shows you a dropdown with all of the configuration options found by the C/C++ Extension on your machine. + ![Compiler Quick Pick](images/intellisense/compiler-quick-pick.png) -Select one of the options available. If you select a compiler, this compiler will also be set as your default compiler. You can return to the Configuration Quick Pick at any point to change which option chosen to configure IntelliSense. -If no options are available in the quick pick, no compiler could be identified in your system. You can browse your machine manually or install a C/C++ compiler. To install on a Windows machine, select the “Help me install a compiler” option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select "Install a compiler" and navigate through the prompts to have a compiler either the Clang or GCC compiler installed on your machine. -### Option 2. Edit your IntelliSense configurations UI +Select one of the options available. If you select a compiler, this compiler will will be used by IntelliSense by default. You can return to the Configuration Quick Pick at any point to change which option is used to configure IntelliSense. + +If no options are available in the quick pick, no compiler could be identified in your system. You can browse your machine manually or install a C/C++ compiler. To install on a Windows machine, select the **Help me install a compiler** option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select **Install a compiler** and navigate through the prompts to have a C++ compiler installed on your machine. + +### Option 2. Edit your IntelliSense configurations through the UI -Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This is an easy to navigate interface of the `c_cpp_properties.json` file. -Set the "Compiler path" field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the "IntelliSense mode" to the architecture-specific variant of the compiler you're using. If you're using a compiler that isn't supported by the C/C++ Extension, you can set the "IntelliSense mode" to `gcc-x64` or `clang-x64` to get IntelliSense for your project. You can also set the "Include path" to the path of any header files that aren't in your workspace or standard library path. +Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This is an interface of the `c_cpp_properties.json` file. +Set the **Compiler path** field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the **IntelliSense mode** to the architecture-specific variant of the compiler you're using. ### Option 3. Edit the `c_cpp_properties.json` file directly -You can edit the `c_cpp_properties.json` file directly to customize your configuration. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`), then the `c_cpp_properties.json` file is found in the `.vscode` folder of your workspace. - Use the `compilerPath` variable to add a compiler. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. -Make sure you have defined the following settings if you are writing to your `c_cpp_properties.json` file: +You can edit the `c_cpp_properties.json` file directly to customize your configuration. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`), then the `c_cpp_properties.json` file is created in the `.vscode` folder of your workspace. +Use the `compilerPath` variable to add a compiler. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. -- IntelliSense mode: The IntelliSense mode to use that maps to a platform and architecture variant of MSVC, gcc, or Clang. -- Include path: You only need to modify the **Include path** if your program includes header files that aren't in your workspace or that aren't in the standard library path.The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. -- For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). -Here's a sample `c_cpp_configuration.json` file on a Windows machine using the default install path for minGW: +Select a tab to see some samples of a `c_cpp_configuration.json` file depending on your operating system: +Sample c_cpp_configuration.json on Windows +
+

Using the default install path for MinGW: ```json { "configurations": [ @@ -95,17 +99,81 @@ Here's a sample `c_cpp_configuration.json` file on a Windows machine using the d "version": 4 } ``` +

+
+
+ +Sample c_cpp_configuration.json on Mac +
+

Using the default install path for clang: +```json +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "macFrameworkPath": [ + "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks" + ], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-clang-arm64" + } + ], + "version": 4 +} +``` +

+
+
+ +Sample c_cpp_configuration.json on Linux +
+

Using the default install path for GCC: +```json +{ + "configurations": [ + { + "name": "Linux-GCC", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/g++", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "gcc-x64", + "browse": { + "path": [ + "${workspaceFolder}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 4 +} +``` +

+
+
+ +## Project level IntelliSense Configuration + +Configuring IntelliSense with a compiler provides you with core IntelliSense features. This is called the base configuration. However, when working with more complex usage scenarios, you might want additional customization such as adding specific include paths, defines, compiler arguments, etc. In this case, you can provide additional configurations either through the `c_cpp_properties.json` file and related settings, a `compile_commands.json` file, or a configuration provider in the form of another VS Code extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). + +A `compile_commands.json` file can be selected for configuration through the same methods as discussed in the[How to configure IntelliSense section](/docs/cpp/configure-intellisense.md#_How-to-configure-IntelliSense): through the configuration quick pick, editing configurations through the UI, or editing the `c_cpp_properties.json` file directly. In the configuration UI, the file can be added under Advanced Configurations and the **Compile commands** field. For example, if your `compile_commands.json` file is in the root of your workspace, enter `${workspaceFolder}/compile_commands.json` in the **Compile commands** field. Otherwise, it can be added to the `c_cpp_properties.json` file directly using the `compileCommands` configuration property. + +Note that if the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, your base configuration (found in `c_cpp_properties.json`) will be used instead (such as your `includePath` and `defines`). If the C/C++ Extension is reverting to the base configuration, this can also be a reason the [language status bar indicator](/docs/cpp/configure-intellisense.md#_Option-1:-Check-for-a-status-bar-indicator) is being shown. -## Advanced-C++-IntelliSense-Configuration +If another extension in VS Code is able to provide C/C++ IntelliSense configuration, this extension can be used as a source for configuration by listing it as a configuration provider. For example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extensions are able to provide this configuration. To add an extension as a configuration provider, either select the extension through the configuration quick pick, add it to configuration UI by editing the **Configuration provider** field under Advanced Settings, or add the `configurationProvider` field to your `c_cpp_properties.json` file. In the case of the CMake extension, the path to add would be `ms-vscode.cmake-tools`. -- `compile_commands.json` file -- Another extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). -- -- If another extension is able to provide the configuration for IntelliSense, this configuration is set as your configuration provider in the C++ Extension. Configuration providers are automatically selected to configure IntelliSense. If the extension's configuration can not be configured, the C++ Extension will fall back to the base configuration provided in your `c_cpp_properties.json` file. This includes your default compiler or any compilers found when querying through the process mentioned above. -- -- For configuring a `compile_commands.json` file, enter the full path of the `compile_commands.json` file into the Compile commands field. For example, if your `compile_commands.json` file is in the root of your workspace, use `${workspaceFolder}/compile_commands.json`. -For configuring another extension, set the Configuration Provider field to the ID of the extension that provides IntelliSense configuration information. For example, use the VS Code extension ID `ms-vscode.cmake-tools` to provide configuration information from the [CMake Tools extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools). -To select `compile_commands.json` as a configuration, add or update the `compileCommands` variable. For configuring another extension, use the `configurationProvider` variable. +If your program includes header files that aren't in your workspace or that aren't in the standard library path, you can modify the **Inlcude Path**. The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. ## Next steps From 4ee57936c462cdacb37bff0db6132bf6948a7573 Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Tue, 31 Oct 2023 16:25:12 -0700 Subject: [PATCH 7/8] Moving around lang stat bar and project level IS --- docs/cpp/configure-intellisense.md | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 9508519c78..455c367b2d 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -4,44 +4,28 @@ Area: cpp TOCTitle: Configure IntelliSense ContentId: bf494c65-12b4-4506-ab6c-1fad76d7ccf1 PageTitle: Configure C/C++ IntelliSense -DateApproved: 10/26/2023 +DateApproved: 10/31/2023 MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extension --- # Configure C/C++ IntelliSense This article is about configuring the C/C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. -C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For more advanced project level configurations, reference the section [Project level IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Project-level-IntelliSense-Configuration). +C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For project level configurations, reference the section [Project level IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Project-level-IntelliSense-Configuration). -## When is IntelliSense automatically configured? +## When will the C/C++ Extension configure core IntelliSense features for me? - A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will scan common paths on your machine for compilers such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are identified and in a secure location, they are automatically configured for IntelliSense. Otherwise, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. +A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will scan common paths on your machine for compilers such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are identified and in a secure location, they are automatically configured for IntelliSense. Otherwise, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. ## How to check whether IntelliSense is configured -If you have a compiler installed, there are multiple options to determine if it has been configured for IntelliSense: - -### Option 1: Check for a status bar indicator - -If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign stating **Configure IntelliSense**. +If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign labeled **Configure IntelliSense**. ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) To configure, select the status bar indicator, which navigates you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The quick pick can help you select or install a C/C++ compiler. -### Option 2: Check the language status bar - -To invoke the language status bar, open a C++ file. Note that the status bar shows the text **{} C++**. Hover over the **{}** symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: - -- **IntelliSense: Ready** = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. -- **IntelliSense: Updating** = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code. -- **IntelliSense: Not configured** = IntelliSense isn't configured, and will not provide you with code completion features. To configure, navigate you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick) as explained below. - - ![language-status-bar](images/intellisense/language-status-bar.png) - -### Option 3: Check the `c_cpp_properties.json` file - -All configuration settings are stored in your project's `c_cpp_properties.json` file. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the `IntelliSense mode` to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +If you do not see a status bar indicator, you can also check your project's `c_cpp_properties.json` file. This file stores all of your configuration settings. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the `IntelliSense mode` to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). ![Command Palette](images/cpp/command-palette.png) @@ -163,18 +147,34 @@ Select a tab to see some samples of a `c_cpp_configuration.json` file depending -## Project level IntelliSense Configuration +## Project Level IntelliSense Configuration -Configuring IntelliSense with a compiler provides you with core IntelliSense features. This is called the base configuration. However, when working with more complex usage scenarios, you might want additional customization such as adding specific include paths, defines, compiler arguments, etc. In this case, you can provide additional configurations either through the `c_cpp_properties.json` file and related settings, a `compile_commands.json` file, or a configuration provider in the form of another VS Code extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). +Configuring IntelliSense with a compiler provides you with core IntelliSense features. This is called the base configuration. When working with more complex usage scenarios, such as setting up a project that requires: -A `compile_commands.json` file can be selected for configuration through the same methods as discussed in the[How to configure IntelliSense section](/docs/cpp/configure-intellisense.md#_How-to-configure-IntelliSense): through the configuration quick pick, editing configurations through the UI, or editing the `c_cpp_properties.json` file directly. In the configuration UI, the file can be added under Advanced Configurations and the **Compile commands** field. For example, if your `compile_commands.json` file is in the root of your workspace, enter `${workspaceFolder}/compile_commands.json` in the **Compile commands** field. Otherwise, it can be added to the `c_cpp_properties.json` file directly using the `compileCommands` configuration property. +- additional include paths, such as a to reference one or many differnet libraries +- specific compiler arguments that influence the behavior of the language(and therefore IntelliSense) -Note that if the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, your base configuration (found in `c_cpp_properties.json`) will be used instead (such as your `includePath` and `defines`). If the C/C++ Extension is reverting to the base configuration, this can also be a reason the [language status bar indicator](/docs/cpp/configure-intellisense.md#_Option-1:-Check-for-a-status-bar-indicator) is being shown. +There are multiple additional ways to configure your IntelliSense. You can provide these additional configurations either through the `c_cpp_properties.json` file and related settings, a `compile_commands.json` file, or a configuration provider in the form of another VS Code extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). -If another extension in VS Code is able to provide C/C++ IntelliSense configuration, this extension can be used as a source for configuration by listing it as a configuration provider. For example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extensions are able to provide this configuration. To add an extension as a configuration provider, either select the extension through the configuration quick pick, add it to configuration UI by editing the **Configuration provider** field under Advanced Settings, or add the `configurationProvider` field to your `c_cpp_properties.json` file. In the case of the CMake extension, the path to add would be `ms-vscode.cmake-tools`. +If another extension in VS Code is able to provide C/C++ IntelliSense configuration, this extension can be used as a source for configuration by listing it as a configuration provider. For example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extensions are able to provide this configuration. To add an extension as a configuration provider, either select the extension through the configuration quick pick, add it to configuration UI by editing the **Configuration provider** field under **Advanced Settings**, or add the `configurationProvider` field to your `c_cpp_properties.json` file. For example, in the case of the CMake extension, the path to add would be `ms-vscode.cmake-tools`. If your program includes header files that aren't in your workspace or that aren't in the standard library path, you can modify the **Inlcude Path**. The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. +Another option to provide intelliSense configuration is a `compile_commands.json` file, which describles the exact compile commands used for every file in a project. This file is often generated by a build system, such as CMake or Make by setting command line arguments when configuring your project. A `compile_commands.json` file can be selected for configuration through the same methods as discussed in the [How to configure IntelliSense section](/docs/cpp/configure-intellisense.md#_How-to-configure-IntelliSense): through the configuration quick pick, editing configurations through the UI, or editing the `c_cpp_properties.json` file directly. In the configuration UI, the file can be added under Advanced Configurations and the **Compile commands** field. For example, if your `compile_commands.json` file is in the root of your workspace, enter `${workspaceFolder}/compile_commands.json` in the **Compile commands** field. Otherwise, it can be added to the `c_cpp_properties.json` file directly using the `compileCommands` configuration property. + +Note that if the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, your base configuration (found in `c_cpp_properties.json`) will be used instead (such as your `includePath` and `defines`). If the C/C++ Extension is reverting to the base configuration, this can also be a reason the [language status bar indicator](/docs/cpp/configure-intellisense.md#_Option-1:-Check-for-a-status-bar-indicator) is being shown. + +### Checking on IntelliSense using the language status bar + +You can determine if IntelliSense is actively working on your file using the language status bar. To invoke the language status bar, open a C++ file. Note that the status bar shows the text **{} C++**. Hover over the **{}** symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: + +- **IntelliSense: Ready** = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. +- **IntelliSense: Updating** = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code. + +![language-status-bar](images/intellisense/language-status-bar.png) + +You can select the pin icon on the right of any item in the language status bar flyout to permanently pin it to your status bar. + ## Next steps - For more information about IntelliSense configuration, see [Customizing default settings](/docs/cpp/customize-default-settings-cpp.md). From c3176d20f47919e85d416442f6a7a3858f63689c Mon Sep 17 00:00:00 2001 From: Alexandra Kemper Date: Wed, 1 Nov 2023 13:22:44 -0700 Subject: [PATCH 8/8] Acrolinx fixes, general feedback --- docs/cpp/configure-intellisense.md | 45 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/docs/cpp/configure-intellisense.md b/docs/cpp/configure-intellisense.md index 455c367b2d..47ee46c9a8 100644 --- a/docs/cpp/configure-intellisense.md +++ b/docs/cpp/configure-intellisense.md @@ -11,21 +11,21 @@ MetaDescription: Configure Visual Studio Code IntelliSense in the C/C++ Extensio This article is about configuring the C/C++ extension to provide C++ specific [IntelliSense](/docs/editor/intellisense.md) suggestions in VS Code. IntelliSense is a helpful tool built into VS Code that provides various code editing features that help you code faster and more efficiently. For example, code completion, parameter info, syntax highlighting, code actions (light bulbs), and member lists are all generated using IntelliSense. -C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler will provide C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For project level configurations, reference the section [Project level IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Project-level-IntelliSense-Configuration). +C/C++ IntelliSense only requires a C/C++ compiler to be installed on your system. The C/C++ compiler provides C++ specific information to IntelliSense, such as the locations of system include paths and other settings. For project level configurations, reference [Project level IntelliSense Configuration](/docs/cpp/configure-intellisense.md#_Project-Level-IntelliSense-Configuration) section. ## When will the C/C++ Extension configure core IntelliSense features for me? -A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C++ Extension will scan common paths on your machine for compilers such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are identified and in a secure location, they are automatically configured for IntelliSense. Otherwise, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected will be set as the default compiler. +A compiler is the only requirement to configure core Intellisense functionality. To identify a compiler for IntelliSense, the C/C++ Extension scans common paths on your machine for compilers such as clang, GCC, MinGW, cygwin, cygwin64, and MSVC. If any of these compilers are identified and in a secure location, they are automatically configured for IntelliSense. Otherwise, a notification is displayed asking you to confirm that this compiler should be configured for IntelliSense. In either of these scenarios, the compiler selected is also set as the default compiler. ## How to check whether IntelliSense is configured -If you don't have IntelliSense configured, the C/C++ Extension shows an indicator in the status bar with a warning sign labeled **Configure IntelliSense**. +If you don't have IntelliSense configured, the C/C++ Extension shows a yellow indicator in the status bar with a warning sign labeled **Configure IntelliSense**. ![configure-intelliSense-indicator-status-bar](images/intellisense/configure-intellisense-indicator.png) -To configure, select the status bar indicator, which navigates you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-Quick-Pick). The quick pick can help you select or install a C/C++ compiler. +To configure, select the status bar indicator, which navigates you to the [configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-quick-pick). The quick pick can help you select or install a C/C++ compiler. -If you do not see a status bar indicator, you can also check your project's `c_cpp_properties.json` file. This file stores all of your configuration settings. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`) in VS Code. Check the `IntelliSense mode` to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +If you do not see a status bar indicator, you can also check your project's `c_cpp_properties.json` file. This file stores all of your IntelliSense configuration settings. Navigate to this file by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). Check the `IntelliSense mode` to find your configuration. To learn more about the `c_cpp_properties.json` file, see the [schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). ![Command Palette](images/cpp/command-palette.png) @@ -39,13 +39,14 @@ Open the quick pick by entering **Select IntelliSense Configuration** in the Com ![Compiler Quick Pick](images/intellisense/compiler-quick-pick.png) -Select one of the options available. If you select a compiler, this compiler will will be used by IntelliSense by default. You can return to the Configuration Quick Pick at any point to change which option is used to configure IntelliSense. +Select one of the options available. If you select a compiler, this compiler is used by IntelliSense by default. You can return to the Configuration quick pick at any point to change which option is used to configure IntelliSense. If no options are available in the quick pick, no compiler could be identified in your system. You can browse your machine manually or install a C/C++ compiler. To install on a Windows machine, select the **Help me install a compiler** option, which redirects you to the step-by-step walkthrough of how to install a C/C++ compiler. On a Mac or Linux machine, select **Install a compiler** and navigate through the prompts to have a C++ compiler installed on your machine. ### Option 2. Edit your IntelliSense configurations through the UI -Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This is an interface of the `c_cpp_properties.json` file. +Open your IntelliSense configuration by selecting **C/C++: Edit Configurations (UI)** from the Command Palette (`kb(workbench.action.showCommands)`). This view is an interface of the `c_cpp_properties.json` file. + Set the **Compiler path** field to the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. Set the **IntelliSense mode** to the architecture-specific variant of the compiler you're using. ### Option 3. Edit the `c_cpp_properties.json` file directly @@ -53,9 +54,9 @@ Set the **Compiler path** field to the full path of the compiler you're using to You can edit the `c_cpp_properties.json` file directly to customize your configuration. Use the **C/C++ Edit Configurations (JSON)** command from the Command Palette (`kb(workbench.action.showCommands)`), then the `c_cpp_properties.json` file is created in the `.vscode` folder of your workspace. Use the `compilerPath` variable to add a compiler. This variable is the full path of the compiler you're using to build your project. For example, when using the default install path for GCC on Linux, the compiler path is `/usr/bin/gcc`. -For more information about the `c_cpp_properties.json` file, see the [c_cpp_properties.json schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). +For more information about the `c_cpp_properties.json` file, view the [schema reference](/docs/cpp/c-cpp-properties-schema-reference.md). -Select a tab to see some samples of a `c_cpp_configuration.json` file depending on your operating system: +Select a tab to see some samples of a `c_cpp_configuration.json` file based on your operating system: Sample c_cpp_configuration.json on Windows
@@ -149,26 +150,34 @@ Select a tab to see some samples of a `c_cpp_configuration.json` file depending ## Project Level IntelliSense Configuration -Configuring IntelliSense with a compiler provides you with core IntelliSense features. This is called the base configuration. When working with more complex usage scenarios, such as setting up a project that requires: +Configuring IntelliSense with a compiler provides you with core IntelliSense features. This steup is called the base configuration. For more complex usage scenarios, such as setting up a project that requires: -- additional include paths, such as a to reference one or many differnet libraries +- additional include paths, such as references to one or multiple different libraries - specific compiler arguments that influence the behavior of the language(and therefore IntelliSense) -There are multiple additional ways to configure your IntelliSense. You can provide these additional configurations either through the `c_cpp_properties.json` file and related settings, a `compile_commands.json` file, or a configuration provider in the form of another VS Code extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension). +There are multiple other ways to configure IntelliSense. You can provide these additional configurations either through the `c_cpp_properties.json` file and related settings, a custom configuration provider in the form of another VS Code extension (for example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extension), or a `compile_commands.json` file. + +### Configuration Providers + +A custom configuration provider is another extension in VS Code which can potentially provide more accurate C++ IntelliSense configuration than the C/C++ Extension. For example, for the CMake or Make build systems, where the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extensions can be configuration providers. To add an extension as a configuration provider, either select the extension through the configuration quick pick, add it to configuration UI by editing the **Configuration provider** field under **Advanced Settings**, or add the `configurationProvider` field to your `c_cpp_properties.json` file. For example, for the CMake extension, the path to add would be `ms-vscode.cmake-tools`. + +The C/C++ Extension scans your system for custom configuration providers. If it identifies only one custom configuration provider, this configuration provider is automatically configured for IntelliSense. If there are multiple configuration providers identified, you need to select which the Extension should use by opening [the configuration quick pick](/docs/cpp/configure-intellisense.md#_Option-1.-Select-a-configuration-option-through-the-configuration-quick-pick). + +### `compile_commands.json` File -If another extension in VS Code is able to provide C/C++ IntelliSense configuration, this extension can be used as a source for configuration by listing it as a configuration provider. For example, the [Makefile Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.makefile-tools) or [CMake Tools](/docs/cpp/CMake-linux.md) extensions are able to provide this configuration. To add an extension as a configuration provider, either select the extension through the configuration quick pick, add it to configuration UI by editing the **Configuration provider** field under **Advanced Settings**, or add the `configurationProvider` field to your `c_cpp_properties.json` file. For example, in the case of the CMake extension, the path to add would be `ms-vscode.cmake-tools`. +Another option to provide intelliSense configuration is a [`compile_commands.json` file](https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html), which describes the exact compile commands used for every file in a project. This file is often generated by a build system, such as CMake or Bazel, by setting command line arguments when configuring your project. A `compile_commands.json` file can be selected for configuration through the same methods as discussed in the [How to configure IntelliSense section](/docs/cpp/configure-intellisense.md#_How-to-configure-IntelliSense): through the configuration quick pick, editing configurations through the UI, or editing the `c_cpp_properties.json` file directly. In the configuration UI, the file can be added under Advanced Configurations and the **Compile commands** field. For example, if your `compile_commands.json` file is in the root of your workspace, enter `${workspaceFolder}/compile_commands.json` in the **Compile commands** field. Otherwise, it can be added to the `c_cpp_properties.json` file directly using the `compileCommands` configuration property. -If your program includes header files that aren't in your workspace or that aren't in the standard library path, you can modify the **Inlcude Path**. The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. +If the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, your base configuration (found in `c_cpp_properties.json`) is used instead (such as your `includePath` and `defines`). If the C/C++ Extension is reverting to the base configuration, the [language status bar indicator](/docs/cpp/configure-intellisense.md#_Option-1:-Check-for-a-status-bar-indicator) will show you the label **Configure IntelliSense** in the status bar. -Another option to provide intelliSense configuration is a `compile_commands.json` file, which describles the exact compile commands used for every file in a project. This file is often generated by a build system, such as CMake or Make by setting command line arguments when configuring your project. A `compile_commands.json` file can be selected for configuration through the same methods as discussed in the [How to configure IntelliSense section](/docs/cpp/configure-intellisense.md#_How-to-configure-IntelliSense): through the configuration quick pick, editing configurations through the UI, or editing the `c_cpp_properties.json` file directly. In the configuration UI, the file can be added under Advanced Configurations and the **Compile commands** field. For example, if your `compile_commands.json` file is in the root of your workspace, enter `${workspaceFolder}/compile_commands.json` in the **Compile commands** field. Otherwise, it can be added to the `c_cpp_properties.json` file directly using the `compileCommands` configuration property. +If you specified a custom configuration provider and a `compile_commands.json` file, the custom configuration provider is queried first for an IntelliSense configuration. -Note that if the compile commands database does not contain an entry for the translation unit that corresponds to the file you opened in the editor, your base configuration (found in `c_cpp_properties.json`) will be used instead (such as your `includePath` and `defines`). If the C/C++ Extension is reverting to the base configuration, this can also be a reason the [language status bar indicator](/docs/cpp/configure-intellisense.md#_Option-1:-Check-for-a-status-bar-indicator) is being shown. +If your program includes header files that aren't in your workspace or that aren't in the standard library path, you can modify the **Include Path**. The C/C++ extension populates the include path by querying the compiler specified by **Compiler path**. If the extension can't find the path for the target system libraries, you can enter the include path manually. -### Checking on IntelliSense using the language status bar +### Checking IntelliSense activity using the language status bar You can determine if IntelliSense is actively working on your file using the language status bar. To invoke the language status bar, open a C++ file. Note that the status bar shows the text **{} C++**. Hover over the **{}** symbol to open the language status bar flyout. The top item in the flyout indicates the IntelliSense status. Here are the different statuses and their meanings: -- **IntelliSense: Ready** = IntelliSense has been configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. +- **IntelliSense: Ready** = IntelliSense is configured for the C/C++ Extension and automatically activates if you interact with the editor, for example, by writing code. - **IntelliSense: Updating** = IntelliSense is actively working to determine any code completions, syntax highlighting, etc. based on changes you're making to your code. ![language-status-bar](images/intellisense/language-status-bar.png)