【vscode配置】配置coderunner运行C/C++
首先在vscode扩展商店中安装coderunner插件
安装后打开项目文件夹
在父目录下新建.vscode文件夹
.vscode下写三个配置文件
c_cpp_properties.json
"compilerPath":后的路径改为自己编译器路径下的g++.exe程序
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:\\w64devkit\\bin\\g++.exe",
"intelliSenseMode": "gcc-x64",
"cppStandard": "c++11",
"cStandard": "c11"
}
],
"version": 4
}
launch.json
"miDebuggerPath":后的路径改为自己编译器路径下的gdb.exe程序
{
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:/w64devkit/bin/gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe 生成活动文件"
}
]
}
task.json
"command": 和 "detail": "compiler: 后的路径改为自己编译器路径下的g++.exe程序
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "D:\\w64devkit\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\w64devkit\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: D:\\w64devkit\\bin\\g++.exe"
}
]
}
配置文件写好后,写好一个cpp文件,点击VSCode右上角装好的code runner插件的三角运行按钮
即可自动编译并运行
在下方弹出的终端中进行输入或查看输出