c++ - 如何在 VS Code 中进行 C++ 开发的初始设置?
问题描述
我尝试通过 YouTube 视频为 VS Code 设置 C++,但它们已经很老了。因此, c_cpp_properties.json和task.json中存在配置错误。
解决方案
- 下载并安装MinGW-w64
- 安装“ C/C++ for Visual Studio Code ”扩展
这都是针对 Window 操作系统的设置。对于其他操作系统,您只需更改c_cpp_properties.json 配置
c_cpp_properties.json文件的示例(您必须添加自己的 MinGW-w64路径):
{
"configurations":
[
{
"name": "Win64",
"includePath": [
"${workspaceFolder}",
"C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\lib\\gcc\\i686-w64-mingw32\\8.1.0",
"C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\i686-w64-mingw32\\include"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"compilerPath": "C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin",
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}",
"C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\lib\\gcc\\i686-w64-mingw32\\8.1.0",
"C:\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\i686-w64-mingw32\\include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
task.json文件
的示例:
{
"version": "2.0.0",
"tasks": [
{
"label": "debug",
"type": "shell",
"command": "",
"args": ["g++","-g", "${relativeFile}", "-o","a.exe"]
},
{
"label": "Compile and run",
"type": "shell",
"command": "",
"args": [
"g++","-g", "${relativeFile}", "-o","${fileBasenameNoExtension}", "&&" , "./${fileBasenameNoExtension}"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": ["relative", "${workspaceRoot}"],
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
}
]
}
Ctrl您可以使用++构建 C Shift++
程序b。
推荐阅读
- stripe-payments - 仅对选定的订阅付款应用 Stripe 优惠券
- python - 深度 Q 网络无法解决 OpenAI CartPole
- c - C:没有参数类型定义的函数
- documentum - 文档错误:[DM_STORAGE_E_BAD_TICKET]
- javascript - 是否可以从手动重新加载 (location.reload();) 中排除脚本执行?
- amazon-web-services - 使用 java sdk 停止 ELB 中的 EC2 实例
- android - android中的PendingIntent.FLAG_UPDATE_CURRENT和0有什么不同?
- linux - u-boot中的fatloat地址限制
- ios - 自定义展开 segue 类在 Swift 中无法正常工作,为什么?
- laravel-5 - Laravel:只显示自己的帖子