Ubuntu VScode C/C++執行配置 launch.json+test.json+C/C++ Compile Run
阿新 • • 發佈:2021-01-21
launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.out",
"args": [],
"stopAtEntry" : false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"preLaunchTask": "build",
"setupCommands" : [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
test.json
{
"version": "2.0.0",
"tasks": [
{
"label": "gcc",
"command": "gcc",
"args": [
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}.out",
"-g",
"-static-libgcc",
"-std=c99"
],
"type": "shell",
"group": "build",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared"
},
"problemMatcher": "$gcc"
},
{
"label": "build",
"type": "shell",
"command": "g++",
"group": {
"kind": "build",
"isDefault": true
},
"args": ["-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out"]
}
]
}
其他執行方式
C++(方法3:使用C/C++ Compile Run外掛)
VSCode的這個外掛更簡單,但只能用於單檔案
C/C++ Compile Run下載
這下根本無需配置task.json和launch.json,儲存後直接按F6自動編譯執行,其他功能見外掛下載頁的how to use