VS Code Configuration C ++ runtime environment

Environment Configuration

 Open in vscode folder -> Create new folder -> select, thus adding directly to vscode in the; or directly to a file into vscode in. Next, create a .vscode folder (note that the name must be .vscode) In this document, it is necessary (in general, each folder there will be such a .vscode configuration file). Note: this folder on the common top-level folder, you do not need to repeat the configuration. In .vscode folder, three new profile, i.e. launch.json, tasks.json, c_cpp_properties.json. Content can be copied into the following:

launch.json

{
     " Version " : " 0.2.0 " ,
     " the Configurations " : [ 
      { 
        " name " : " (gdb) Launch " , // configuration name will appear in the drop-down menu in the launch configuration 
        " of the type " : " cppdbg " , // type of configuration, there is only cppdbg 
        " request " : " Launch " , // request type of configuration, may launch (start) or attach (additional) 
        " Program ": "workspaceFolder} {$ /} $ {fileBasenameNoExtension .exe " , // path of the program to be debugged 
        " args " : [], // command to the debugging program when the program line arguments, generally set to be empty 
        " stopAtEntry " : false , // when set to true program will halt at the entrance to the program, usually set to false 
        " CWD " : " $ {workspaceFolder} " , // when the debugger working directory, usually $ {workspaceRoot} That Code directory 
        " Environment " : [],
         " externalConsole " : to true ,// whether to display the console window when debugging, generally set to true display console 
        "MIMode " : " GDB " ,
         " miDebuggerPath " : " D: \\ Program Files mingw64 \\ \\ \\ gdb.exe bin " , // miDebugger path, attention here to the corresponding path MinGw 
        " preLaunchTask " : " ++ G " , // debug session before the start of task execution, typically the compiler, c ++ as g ++, c is gcc 
        " setupCommands " : [ 
          { 
            " the Description " : " the Enable Pretty-Printing for gdb " ,
             "text": "-enable-pretty-printing",
            "ignoreFailures": true
          }
        ]
      }
    ]
  }

 

 tasks.json

{
    "version": "2.0.0",
    "command": "g++",
    "args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"],   
    "problemMatcher": {
        "owner": "cpp",
        "fileLocation": ["relative", "${workspaceFolder}"],
        "pattern": {
            "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
            "file": 1,
            "line": 2,
            "column": 3,
            "severity": 4,
            "message": 5
        }
    }
}

c_cpp_properties.json

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../include",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
                "D:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "D:/Program Files/mingw64/bin/g++.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

 

Test case

Create a new folder inside main.cpp

code show as below:

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{

    vector<string> msg {"Hello", "C++", "World", "from", "VS Code!"};

    for (const string& word : msg)
    {
        cout << word << " ";
    }
    cout << endl;
    getchar();
}

 

operation result:

 

Guess you like

Origin www.cnblogs.com/cslong68/p/11697197.html