VSCode-Anywhere
  • Introduction
  • Installation
    • Requirements
      • Windows requirements
      • Linux requirements
      • MacOS requirements
    • Quickstart
    • Advanced
      • Windows installation
      • Linux installation
      • MacOS installation
  • Modules
    • Module installation
    • Module update
    • Module settings
      • Global settings
        • brew settings
        • chocolatey settings
        • env settings
        • msys2 settings
        • nix settings
        • scoop settings
        • vscode settings
        • zeal settings
    • Modules list
      • Ansible
      • Bash
      • C / C++
      • C#
      • Custom
      • Deepcode
      • Docker
      • Fonts
      • Git
      • Go
      • HTML
      • Java
      • JavaScript / TypeScript
      • Markdown
      • Perl
      • PHP
      • Platformio
      • PowerShell
      • Puppet
      • Python2
      • Python3
      • Remote
      • Rest
      • ReStructuredText
      • Ruby
      • Saltstack
      • VSCode
    • Custom modules
  • Structure
    • apps
    • conf
      • saltstack
        • conf-offline
        • conf
        • pillar
        • states
    • tools
      • env
      • install
      • link
      • update
      • vscode
      • vscode-anywhere
  • Tutorials
    • Youtube tutorials
  • Release notes
    • V2
      • V2.0.0
    • V1
  • FAQ
Powered by GitBook
On this page
  • About
  • Installation
  • Requirements
  • Windows examples
  • VSCode
  • VSCode extensions
  • VSCode settings
  • VSCode keybindings
  • Software
  • Windows software
  • Linux software
  • MacOS software
  • Documentation
  • VSCode-Anywhere
  • Environment
  • Windows environment
  • Linux environment
  • Specific settings

Was this helpful?

  1. Modules
  2. Modules list

C / C++

PreviousBashNextC#

Last updated 4 years ago

Was this helpful?

About

This module contains 2 languages:

Installation

vscode-anywhere:
    c_cpp:
        enabled: True

Requirements

After installing this module, you must configure it because it doesn't work out of the box.

Indeed to work the module ms-vscode.cpptools needs to have a valid.vscode/c_cpp_properties.json file.

You can configure it by running the command C/C++: Edit Configurations (UI) or C/C++: Edit Configurations (JSON) from the Command Palette (Ctrl+Shift+P).

You could also read:

Windows examples

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang build active file",
            "command": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang.exe",
            "args": [
                "-std=c11",
                "-Wall",
                "-Wextra",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            }
        },
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang++.exe",
            "args": [
                "-std=c++17",
                "-Wall",
                "-Wextra",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            }
        }
    ]
}
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) clang",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Activer l'impression en mode Pretty pour gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "clang build active file"
        },
        {
            "name": "(gdb) clang++",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Activer l'impression en mode Pretty pour gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "clang++ build active file"
        }
    ]
}

There are examples and assuming you have installed in the default directory C:\VSCode-Anywhere.

VSCode

VSCode extensions

ms-vscode.cpptools

jbenden.c-cpp-flylint

matepek.vscode-catch2-test-adapter

VSCode-Anywhere does not install Catch2, Google Test or doctest. You have to install them by yourself.

ms-vscode.cmake-tools

VSCode settings

Global settings

{
    "dash.languageIdToDocsetMap.c": [
        "c"
    ],
    "C_Cpp.default.cStandard": "c11",
    "C_Cpp.default.cppStandard": "c++17",
    "c-cpp-flylint.flexelint.enable": true,
    "c-cpp-flylint.cppcheck.enable": true,
    "c-cpp-flylint.clang.enable": false
}

If llvm is enabled:

{
    "c-cpp-flylint.flexelint.enable": false,
    "c-cpp-flylint.cppcheck.enable": false,
    "c-cpp-flylint.clang.enable": true
}

Windows settings

Global settings for Windows:

{
    "cmake.cmakePath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\cmake.exe"
}

If llvm is disabled:

{
    "C_Cpp.default.compilerPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\gcc.exe",
    "c-cpp-flylint.clang.executable": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\g++.exe",
    "code-runner.executorMap.c": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\gcc.exe $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe",
    "code-runner.executorMap.cpp": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\g++.exe $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe",
    "c-cpp-flylint.cppcheck.executable": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\cppcheck.exe"
}

If llvm is enabled:

{
    "C_Cpp.default.compilerPath": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang.exe",
    "c-cpp-flylint.clang.executable": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang.exe",
    "code-runner.executorMap.c": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang.exe $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe",
    "code-runner.executorMap.cpp": "C:\\VSCode-Anywhere\\apps\\scoop\\apps\\msys2\\current\\mingw64\\bin\\clang++.exe $fileName -o $fileNameWithoutExt.exe && $fileNameWithoutExt.exe"
}

Assuming you have installed in the default directory C:\VSCode-Anywhere.

Linux settings

Global settings for Linux:

{
    "cmake.cmakePath": "/home/linuxbrew/.linuxbrew/bin/cmake"
}

If llvm is disabled:

{
    "code-runner.executorMap.c": "/home/linuxbrew/.linuxbrew/bin/gcc $fileName -o $fileNameWithoutExt && $fileNameWithoutExt",
    "code-runner.executorMap.cpp": "/home/linuxbrew/.linuxbrew/bin/g++ $fileName -o $fileNameWithoutExt && $fileNameWithoutExt",
    "C_Cpp.default.compilerPath": "/home/linuxbrew/.linuxbrew/bin/gcc",
    "c-cpp-flylint.cppcheck.executable": "/home/linuxbrew/.linuxbrew/bin/cppcheck"
}

If llvm is enabled:

{
    "code-runner.executorMap.c": "/home/linuxbrew/.linuxbrew/bin/clang $fileName -o $fileNameWithoutExt && $fileNameWithoutExt",
    "code-runner.executorMap.cpp": "/home/linuxbrew/.linuxbrew/bin/clang++ $fileName -o $fileNameWithoutExt && $fileNameWithoutExt",
    "C_Cpp.default.compilerPath": "/home/linuxbrew/.linuxbrew/bin/clang",
    "c-cpp-flylint.clang.executable": "/home/linuxbrew/.linuxbrew/bin/clang"
}

VSCode keybindings

Software

Windows software

msys2

if llvm is disable:

if llvm is enabled:

Linux software

brew

If llvm is disable:

If llvm is enabled:

MacOS software

brew

If llvm is disable:

If llvm is enabled:

Documentation

VSCode-Anywhere

Environment

Windows environment

No environment.

Linux environment

Specific settings

llvm

vscode-anywhere:
  c_cpp:
    enabled: False
    llvm: True

is a general-purpose, procedural computer programming language supporting structured programming, lexical variable scope, and recursion, while a static type system prevents unintended operations.

is a general-purpose programming language created by Bjarne Stroustrup as an extension of the C programming language, or C with Classes.

Change enable from False to True in the c_cpp section (cf ).

You can also take a look at the .

C/C++: Edit Configurations
C/C++: Edit Configurations (UI)

For more details read and how to configure it with:

You can also create a file .vscode/tasks.json to compile your program:

You can also create the .vscode/launch.json file to run the :

This adds language support for C/C++ to Visual Studio Code, including features such as and .

C++ completion

This is an advanced, modern, static analysis extension for C/C++ that supports a number of back-end analyzer programs.

This allows you to run your , , and (experimental) tests for Visual Studio Code.

Cpp tests

provides the native developer a full-featured, convenient, and powerful workflow for CMake-based projects in Visual Studio Code.

For more information take a look at .

No .

To enable , set llvm to True.

C
C++
module installation
VSCode-Anywhere c_cpp module configuration
the official configuration
Mingw on Windows
GCC with Windows Subsystem for Linux
GCC on Linux
Clang on MacOS
Debugging
Editing
Settings
c_cpp_properties.json
task
debugger
extension
IntelliSense
debugging
extension
extension
Catch2
Google Test
doctest
CMake Tools
the official documentation
keybindings
mingw-w64-cmake
mingw-w64-make
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gdb
mingw-w64-x86_64-cppcheck
mingw-w64-x86_64-clang
mingw-w64-x86_64-lldb
cmake
make
gcc
gdb
cppcheck
llvm
gcc
gdb
cppcheck
llvm
C
C++
llvm