vscode 怎么配置c语言和vscode工作区是什么,请另行百度
参考了许多资料,有帮助请点个赞
我的工作区设置如下
将生成exe移动到固定的文件夹,调试时打开外部终端
参考注释,复制请修改所有出现的路径为你对应的路径
{
"folders": [
{
"path": "..\\task\\helloc"
},
{
"path": "..\\task\\Ctest"
}
],
"settings": {
"files.defaultLanguage": "c", // ctrl+N新建文件后默认的语言
"editor.formatOnType": true, // 输入分号(C/C++的语句结束标识)后自动格式化当前这一行的代码
"editor.suggest.snippetsPreventQuickSuggestions": false, //不知道
"C_Cpp.clang_format_sortIncludes": true, // 格式化时调整include的顺序(按字母排序)
"editor.fontSize": 16,
"C_Cpp.default.cppStandard": "c++14",
"C_Cpp.default.cStandard": "c11",
// "C_Cpp.default.includePath": [
// "D:\\mingw64\\lib"
// ],//加了环境变量,可注释掉
"C_Cpp.default.intelliSenseMode": "windows-gcc-x64",
"debug.console.fontSize": 16,
"debug.onTaskErrors": "showErrors", //报错设置
"C_Cpp.clang_format_style": "Visual Studio",
"editor.quickSuggestions": true, //显示建议
"editor.formatOnSave": true, //保存格式化
// "files.exclude": {
// "**/*.exe": true,
// }, //隐藏文件
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "g++.exezlh",
"type": "cppdbg",
"request": "launch",
"program": "D:/daskzlh/task/cexe/${fileBasenameNoExtension}.exe", //存放位置,不喜欢放一块,可另行修改,修改注意task的生成exe位置也要修改
"args": [],
"stopAtEntry": false,
"cwd": "D:/daskzlh/task/cexe",
"environment": [],
"externalConsole": true,//外部终端
"internalConsoleOptions": "openOnFirstSessionStart", // 如果不设为neverOpen,调试时会跳到“调试控制台”选项卡,你应该不需要对gdb手动输命令吧?
"MIMode": "gdb",
//"miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "zlhc",
}
]
},
"tasks": {
"version": "2.0.0",
"tasks": [
{
"label": "zlhc",
"type": "process",
"command": "g++",
"args": [
"-g",
"${file}",
"-o",
"D:/daskzlh/task/cexe/${fileBasenameNoExtension}.exe", //存放位置
"-fexec-charset=GBK"
],
"group": {
"kind": "test",
"isDefault": true
}
}
],
"presentation": {
"echo": false,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false, //如注释
"clear": true, //清屏
"close": true,
},
"problemMatcher": "$gcc" // 捕捉编译时终端里的报错信息到问题面板中,修改代码后需要重新编译才会再次触发
// 本来有Lint,再开problemMatcher就有双重报错,但MinGW的Lint效果实在太差了;用Clangd可以注释掉
}
}
不喜欢我的设置,可参考注释调整