记录一下vscode的配置文件
1. windows
要安装MinGW
1). launch.json
{
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\build\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files (x86)\\mingw64\\bin\\gdb.exe",
"preLaunchTask": "C/C++: g++.exe build active file",// 和tasks.json里面的label一致
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
2). tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files (x86)\\mingw64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
//"-D_USE_32BIT_TIME_T",
//"${fileDirname}\\*.cpp",
"${fileDirname}\\*.c",
"-pthread",
"-fexec-charset=GBK",//防止乱码
//"${file}",
"-lz",
"-o",
"${fileDirname}\\build\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: \"C:\\Program Files (x86)\\mingw64\\bin\\g++.exe\""
}
]
}
2. remote linux
1). 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":"myexe : makefile build and debug",
"type":"cppdbg",
"request":"launch",
"program":"${fileDirname}/${fileBasenameNoExtension}", //执行这个文件,相当于命令行中输入这行
"args":[],
"stopAtEntry":false, //大概是表示是否在main函数处停下,类似在main上打断点。
"cwd":"${workspaceRoot}", //表示在哪个目录下执行program,相当于命令行中输入cd 该行
"environment":[],
"MIMode":"gdb",
"miDebuggerPath":"/usr/bin/gdb", //调试工具的路径
"preLaunchTask": "C/C++: gcc build active file",
"setupCommands":[
{
"description":"Enable pretty-printing for gdb",
"text":"-enable-pretty-printing", //gdb下执行的命令,启用整齐打印,就是让gdb打印的东西好看一点。
"ignoreFailures":true
},
{
"description":"Let User defined signal 1 not appear",
"text":"handle SIGUSR1 nostop noprint",
"ignoreFailures":true
}
],
//"internalConsoleoptions":"openOnSessionstart",
}
]
}
2). tasks.json
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc build active file",
"command": "/usr/bin/gcc",
"args": [
"-fdiagnostics-color=always",
"-g",
"${fileDirname}/*.c",
"-lpthread",
"-lz",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}