伸手党进:具体步骤主要是这篇:Hudiscount-Vscode配置C/C++环境
MinGW-W64 x86_64-win32-seh高速下载
去目录1的第二个链接,并将压缩包解压至一个你觉得合适的路径,并配置环境变量,具体配置步骤见目录1的第一个链接;
建议先新建一个文件夹,将C/C++的环境(包括.json文件)全部保存在这个文件夹里,配置其他语言的环境时也是如此,这样不会乱。
同目录1的第一个链接;
到了第(7)步时,小虫子那段,我直接跳过(主要是也没看懂,试了下也没啥用),因为之前的一些VScode配置经验告诉我最重要的是.json文件的内容不要错就可以,
参考我的三个.json:
launch.json:
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "g++.exe - 生成和调试活动文件","type": "cppdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin","environment": [],"externalConsole": true,"MIMode": "gdb","miDebuggerPath": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/gdb.exe","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "C/C++: g++.exe 生成活动文件"}]
}
tasks.json:
{"version": "2.0.0","tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "编译器: D:\\VScode_C\\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe"}]
}
c_cpp _properties.json:
{"configurations": [{"name": "Win32","includePath": ["${workspaceFolder}/**"],"defines": ["_DEBUG","UNICODE","_UNICODE"],"compilerPath": "D:/VScode_C/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/bin/g++.exe","cStandard": "gnu17","cppStandard": "gnu++14","intelliSenseMode": "windows-gcc-x64"}],"version": 4
}
实际上修改完Configurations后,
c_cpp _properties.json会自动修改。
C版本:
#include
int main()
{printf("Hello,world!\n"); return 0;
}
C++版本:
#include
using namespace std;int main(){cout<<"Hello,VScode!"<
神奇的是C的输出直接跳转至VScode输出,更方便,可能是之前装过coderunner的事;
而C++的输出依旧是.exe黑框框弹窗: