Skip to content

Instantly share code, notes, and snippets.

@trungnt13
Last active April 24, 2023 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trungnt13/4c96393bc2bf6063f1e5a20727ccf7b1 to your computer and use it in GitHub Desktop.
Save trungnt13/4c96393bc2bf6063f1e5a20727ccf7b1 to your computer and use it in GitHub Desktop.
[VSCode] C/C++ c_cpp_properties.json
// env: an array of user-defined variables for substitution in configurations
// configurations: an array of configuration objects for IntelliSense engine
// version: tracks current version of c_cpp_properties.json file
{
"env": {
"myDefaultIncludePath": [
"${workspaceFolder}",
"${workspaceFolder}/include"
],
"myCompilerPath": "/usr/local/bin/gcc-7"
},
// name: "Linux", "Mac", "Win32"
// compilerPath: "/usr/bin/gcc" or "/usr/bin/clang"
// compilerArgs: "-Wall", "-Wextra", "-std=c++17", "-stdlib=libc++"
// intelliSenseMode: "macos-clang-arm64", "msvc-x64", "gcc-x64", "clang-x64"
// includePath: specify ** to indicate recursive search (e.g. "${workspaceFolder}/**")
// defines: list of preprocessor while parsing files (e.g. "VERSION=1")
// cStandard: "c11", "c17"
// cppStandard: "c++11", "c++14", "c++17", "c++20"
// configurationProvider: ID of a VS Code extension that can provide IntelliSense configuration information for source files, "ms-vscode.cmake-tools"
// windowsSdkVersion: versions of the Windows SDK include path to use on Windows (e.g. "10.0.17134.0")
// macFrameworkPath: "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
// forcedInclude: list of files that should be included before any other characters in the source file are processed
// compileCommands: 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 (https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html) and (https://clang.llvm.org/docs/JSONCompilationDatabase.html)
// browse: set of properties used when "C_Cpp.intelliSenseEngine" is set to "Tag Parser" - "fuzzy" IntelliSense
// - path: if omitted, includePath will be used. Searching on these paths is recursive by default. Specify * to indicate non-recursive search
// - limitSymbolsToIncludedHeaders: if true, only symbols from included headers will be added to the database
// - databaseFilename: if omitted, the database will be stored in the workspace folder. If set to "", the database will be stored in memory
"configurations": [
{
"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": "c11",
"cppStandard": "c++17",
"compileCommands": "/path/to/compile_commands.json",
"browse": {
"path": [
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
// use the variable ${command:cpptools.activeConfigName} in tasks.json or launch.json to query the current
// active configuration from c_cpp_properties.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment