I mac version 10.12.5, Vscode version is 1.13
Step is very simple, add a variety of C + + related Plug-ins, reload once, restart Vscode.
Create a. Vscode folder under the Helloworld.cpp folder and create 2 files in. vscode: Tasks.json, Launch.json
The contents of each file are followed by:
Tasks.json: (compilation configuration, that is, the process of generating a.out with CPP)
{
//https://go.microsoft.com/fwlink/? linkid=733558
//For the documentation about the Tasks.json format
"version": "0.1.0",
"command": "g++", //command and args are combined to compile the C + + command, that is g++-G xxx.cpp-o a.out "Isshellcommand"
: True,
"args": ["G", "${file}", "-O", "A.out"], //${file} represents any file name, instead of Helloworld.cpp
"showoutput": "Always",
"Problemmatcher": { // Regular match, delete the useless symbol
"owner": "CPP",
"filelocation": ["Relative", "${workspaceroot}"],
"pattern": {
" RegExp ":" ^ (. *):(\\d+):(\\d+): \\s+ (Warning|error): \\s+ (. *) $ ",
" file ": 1,
" line ": 2,
" column ": 3,
"Severity": 4,
"message": 5
}
}
}
Launch.json: (Debug Configuration, which is the process of running a.out)
{
"version": "0.2.0", "
Configurations": [
{
"name": "(LLDB) Launch",
"type": "cppdbg",
" Request ":" Launch ",
" program ":" ${workspaceroot}/a.out ",//debug, that is, run a.out file
" args ": [],
" Stopatentry ": False,
"CWD": "${workspaceroot}",
"Environment": [],
"Externalconsole": True,
"Mimode": "Lldb",
"Prelaunchtask": "g++"//representing the g++ instruction in Tasks.json before executing Launch.json}
]
}
After configuration, press F5 can be arbitrary in the working directory of CPP file for a key to compile and run debugging