c_cpp_properties.json:
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
"-Wall",
"-Wextra",
"-Wpedantic"
]
}
],
"version": 4
}
launch.json:
{
"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",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "Hello"
},
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"cwd": "/home/sqs/桌面/test期末",
"environment": [],
"program": "/home/sqs/桌面/test期末/build/Debug/outDebug",
"internalConsoleOptions": "openOnSessionStart",
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
settings.json:
{
"C_Cpp_Runner.cCompilerPath": "/usr/bin/gcc",
"C_Cpp_Runner.cppCompilerPath": "/usr/bin/g++",
"C_Cpp_Runner.debuggerPath": "/usr/bin/gdb",
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic"
],
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.excludeSearch": [],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false
}
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Hello", //一定要和Launch.json-preLaunchTask的参数一致
"type": "shell", //无需修改
"command": "g++", //这里我们使用的 g++ 命令
"args": [ //这一部分是自己添加的,是给命令添加的参数
//实际就是在终端执行(以 Main.cpp为例):
// g++ -g Main.cpp -o Main.out
//命令执行后,在文件空间下出现Main.out文件,这样 Launch.json文件就可以负责运行该可执行文件了
"-g",
"${file}",
"-o",
"${fileBasenameNoExtension}.out"
]
}
]
}