首页 / C++ / vs code 配置c/c++环境
vs code 配置c/c++环境
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了vs code 配置c/c++环境,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1686字,纯文字阅读大概需要3分钟。
内容图文
![vs code 配置c/c++环境](/upload/InfoBanner/zyjiaocheng/650/2435b4dd00d249c68c9ec24808c6d94b.jpg)
1. 编译
通过 code-runner插件 运行编译
安装code-runner
后在settings.json
中找到code-runner.executorMap
,可以看到其中的cpp
文件运行方式为
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
2. 调试
c_cpp_properties.json: 这个文件现在的VScode版本已经不需要了
task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"command": "g++",
"args": [
"-g",
"-std=c++11",
// "${workspaceFolder}/${file}",
// "${file}",
"${workspaceFolder}/${fileBasenameNoExtension}.cpp",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}.o",
],// 编译命令参数
"problemMatcher":{
"owner": "cpp",
"fileLocation":[
"relative",
"${workspaceFolder}/Documents"
],
"pattern":[
{
"regexp": "^([^\\\\s].*)\\\\((\\\\d+,\\\\d+)\\\\):\\\\s*(.*)$",
"file": 1,
"location": 2,
//"message": 3
}
]
},
"group": {
"kind": "build",
"isDefault": true
}
}
//"command": "g++",
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}.o",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/Documents",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "g++",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
]
}
//"program": "${workspaceFolder}/${fileBasenameNoExtension}.o",
//"cwd": "${workspaceFolder}",
内容总结
以上是互联网集市为您收集整理的vs code 配置c/c++环境全部内容,希望文章能够帮你解决vs code 配置c/c++环境所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。