Skip to content

Instantly share code, notes, and snippets.

@tapyu
Last active May 31, 2025 04:20
Show Gist options
  • Select an option

  • Save tapyu/8bced1527e3fdc89e6ab7f4023643000 to your computer and use it in GitHub Desktop.

Select an option

Save tapyu/8bced1527e3fdc89e6ab7f4023643000 to your computer and use it in GitHub Desktop.
C/C++-related files for development in Vscode

Config files to debug C/C++ code in Vscode

Language: Cpp
BasedOnStyle: Google
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlignTrailingComments: true
ColumnLimit: 80
DerivePointerAlignment: false
LambdaBodyIndentation: OuterScope
// file is specific to the C/C++ extension for VS Code. It is used
// to configure settings related to IntelliSense, providing
// - include paths and code navigation
// - error checking
// - and other language-specific settings.
// It is primarily focused on setting up the environment for editing
// and understanding the code, rather than building or debugging it.
// Note that some configs (e.g., `intelliSenseMode` or the C/C++
// standard) can be set in `settings.json`, whether in local (in
// `.vscode/`) or in user settings (in ~/.config/Code/).
// When there are conflicting settings between `settings.json` and
// `c_cpp_properties.json`, Visual Studio Code (VSCode) will prioritize
// the settings in `c_cpp_properties.json` over those in `settings.json`
// for IntelliSense-related configurations. Therefore, use this file
// for fine tweaking.
// NOTE: https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
{
"configurations": [
{
"name": "My_C/C++_Linux_cfg", // used to differentiate between multiple configurations within a single project or workspace. If you have only one, this doens't make a relevant differece. You can see which config is select in the status bar
"includePath": [
"${workspaceFolder}/**", // An include path is a folder that contains header files
"/usr/include", // (such as `#include "myHeaderFile.h"`) that are included
"/usr/include/poppler" // in a source file. Add other paths here
],
"defines": [], // used to set preprocessor macros that will be applied during IntelliSense parsing. This helps the C/C++ extension understand your code better and provide accurate code completion, navigation, and error checking (?)
"compilerPath": "/usr/bin/g++", // (optional) The full path to the compiler you use to build your project to enable more accurate IntelliSense
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4 // don't edit this field. It tracks the current version. If it is wrongly changed or deleted, this file is overwritten with a minimal snippet configuration whenever it is saved
}
// used to define debugging configurations. These configurations
// specify how the debugger should launch and interact with your
// application. Each configuration includes settings for the
// debugger type, the program to debug, and any arguments or
// environment variables needed.
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ debug in Vscode", // configures how VS Code will launch the debugger for your application
"type": "cppdbg",
"request": "launch", // Specifies the type of request. launch means to start a new debug session.
"program": "${workspaceFolder}/main", //path to your program
"args": [], // array of command-line arguments to pass to the program when it starts
"stopAtEntry": false,
"cwd": "${workspaceFolder}", // current directory where the program in launch
"environment": [], // array of environment variables to set for the debug session
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// The tasks.json file is used to define tasks that can be executed in VS Code.
// These tasks can be anything from building your project to running tests or
// cleaning up build artifacts.
// You can execute tasks defined in tasks.json directly from the Command Palette
// (Ctrl+Shift+P) by typing "Run Task" and selecting the task you want to
// execute. For example, you can run the build task to compile your project.
// This file defines a build task to compile your C/C++. If this task is the
// default one, you can press `ctrl+shift+B` to run it. Concerning how to
// build your C/C++ project, it really depends on the developer tastes and
// the project complexity. Toy projects can build it by directly running
// the compiler (`gcc` or `g++`), but real projects usualy relies on build
// systems, such as `Makefile` and `CMake`.
{
"version": "2.0.0",
"tasks": [
{
"label": "Build my C/C++ project", // when pressing Ctrl+Shift+P and selecting `Run Task`, this name will appear
"type": "shell",
"command": "make", // Change if want to use another approach
"group": {
"kind": "build", // Indicates that this task is associated with the build process (we can have other kind of tasks, such as test, cleaning, etc.)
"isDefault": true
},
"problemMatcher": { // VS Code can process the output from a task with a problem matcher. Problem matchers scan the task output text for known warning or error strings, and report these inline in the editor and in the Problems panel.
"owner": "cpp", // helps Visual Studio Code organize and present errors and warnings in a relevant context to the user. For example, if you're working on a C/C++ project and the problem matcher's owner is set to "cpp", VSCode will associate errors and warnings detected by this problem matcher with C/C++ files. "Associating" errors and warnings with a specific programming language or file type allows Visual Studio Code to provide targeted assistance and support tailored to the user's current development context
"fileLocation": ["relative", "${workspaceFolder}"], // specifies that file paths in error messages are relative to the workspace folder.
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
// NOTE: https://stackoverflow.com/questions/58581500/how-to-fix-debugger-in-vscode-if-you-have-makefile-project-on-c
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment