VSCode配置C++环境,vscode配置c环境
分享于 点击 6435 次 点评:76
VSCode配置C++环境,vscode配置c环境
VSCode配置C++环境
IDE用惯了,换编辑器写被坑傻了。
VSCode环境的配置都由.json数据构成,全部放在workingFolder的.vscode文件夹内,默认是隐藏的,因为这是配置文件啊。
1.配置settings
如果想改字体大小什么的,直接搜索命令open settings,在user.setting里改。
2.生成c_cpp_properties.json
Command shift P + Edit configuration
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\lib\\gcc\\i686-w64-mingw32\\8.1.0\\include\\c++"
],
"defines": [],
"windowsSdkVersion": "10.0.16299.0",
"compilerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
3. 生成tasks.json
这个文件很重要,在这文件里要说明你想执行的任务。
"tasks": [
{
"label": "build", # 这是任务的标签,也就是名字,在run task时会体现
"type": "shell", # 通过shell运行你的命令
"command": "g++", # 指定编译器命令,参数作用看我上一篇博客,gcc需要额外链接
"args": [
"first.cpp",
"test.cpp", # 参数
"-o",
"main.exe"
]
},
{
"label": "build-debug",
"type": "shell",
"command": "g++",
"args": [
"-g",
# 生成可调试文件
"first.cpp",
"-o",
"debug.exe"
]
}
]
4.生成launch.json
Configure Task Runner,
debug->open configuration,生成launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
# 调用生成的调试文件名字,第二个task生成的
"program": "${workspaceFolder}/debug.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
# gdb.exe路径
"miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
# 可以省去debug的第一步
"preLaunchTask": "build-debug"
}
]
}
相关文章
- 暂无相关文章
用户点评