vs code 配置c/c++环境
2024-10-08 01:01:39
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}",
最新文章
- win10 系统怎么获取最高管理员权限删除文件
- 网页样式——各种炫酷效果持续更新ing...
- JAVA System.getProperty() 与 System.getenv() 差异及示例
- WinRAR命令行
- C#的Enum——枚举
- 原创docker dcos 的安装
- Effective Java 38 Check parameters for validity
- Mysql主从库同步错误:1062 Error 'Duplicate entry '1438019'
- 在Spring中使用脚本
- eclipse中代码注释
- CCNA长语
- lintcode :旋转字符串
- _js day12
- html 上传文件
- java Runtime类
- React+webpack开发环境的搭建
- javascript中的数组对象
- [AST实战]从零开始写一个wepy转VUE的工具
- 针对监控摄像机(海康、大华等)录像 .h264 文件的流媒体播放设计
- day46-python爬虫学习