|
发表于 2019-6-28 15:21:26
|
显示全部楼层
本楼为最佳答案
本帖最后由 虚无→与→飘渺 于 2019-6-29 16:23 编辑
如果你有安装Visual Studio的Windows平台通用开发组件的话在VS Code里面会安装完C/C++扩展后它会自动找到VS的编译器好像叫cl.exe,如果你没有安装Visual Studio或者其中的Windows平台通用开发组件的话你需要自己配置编译器,好像叫Mingw64,具体安装步骤百度一搜“VS Code写C或者C++”就有了
其实如果不是条件很苛刻,我建议lz直接用Visual Studio,这比用VS Code要方便的多,VS Code比较适合写Python,JavaScript,HTML/CSS之类的,些其他语言配置起来会比较麻烦,虽然我也用VS Code给Arduino(基于C/C++)编程吧23333333
当时配置的时候也是烦的一比,总之如果不是对VS Code有什么偏爱的话建议用Visual Studio
以下是我的launch和tasks的json配置文件的内容,你可以参考一下
由于用cl.exe好像会有莫名其妙的问题,所以我这个配置文件用的都是gcc(就是上头说的那个Mingw64)
这个是launch.json
- {
- // 使用 IntelliSense 了解相关属性。
- // 悬停以查看现有属性的描述。
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
- "version": "0.2.0",
- "configurations": [
- {
- "name": "gcc.exe build and debug active file",
- "type": "cppdbg",
- "request": "launch",
- "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
- "args": [],
- "stopAtEntry": false,
- "cwd": "${workspaceFolder}",
- "environment": [],
- "externalConsole": false,
- "MIMode": "gdb",
- "miDebuggerPath": "D:\\mingw64\\bin\\gdb.exe",
- "setupCommands": [
- {
- "description": "Enable pretty-printing for gdb",
- "text": "-enable-pretty-printing",
- "ignoreFailures": true
- }
- ],
- "preLaunchTask": "gcc.exe build active file"
- }
- ]
- }
复制代码
这个是tasks.json
- {
- "tasks": [
- {
- "type": "shell",
- "label": "gcc.exe build active file",
- "command": "D:\\mingw64\\bin\\gcc.exe",
- "args": [
- "-g",
- "${file}",
- "-o",
- "${fileDirname}\\${fileBasenameNoExtension}.exe"
- ],
- "options": {
- "cwd": "D:\\mingw64\\bin"
- }
- }
- ],
- "version": "2.0.0"
- }
复制代码 |
|