代码开始前 - VSCode - C/C++配置
需要软件
- VSCode
- Mingw64
需要插件
调试
- C/C++ Extension Pack 这个里面包含了基本上所有需要的插件
This extension pack includes a set of popular extensions for C++ development in Visual Studio Code:- C/C++
- C/C++ Themes
- CMake
- CMake Tools
- C/C++ 用于补全 IntelliSense,调试 debugging, 浏览 code browsing.
- C/C++ Themes 主题
运行
- Code Runner 可以在输出栏显示代码中的输出(不能调试,调试时没有)
配置文件
launch.js
{
"configurations": [
{
"name": "C/C++: gcc.exe 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "D:/Dev-Cpp/MinGW64/bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "D:\\Dev-Cpp\\MinGW64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 生成活动文件"
}
],
"version": "2.0.0"
}
task.js
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe 生成活动文件",
"command": "D:/Dev-Cpp/MinGW64/bin/gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:/Dev-Cpp/MinGW64/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
],
"version": "2.0.0"
}
c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c11",
"cppStandard": "c++14",
"intelliSenseMode": "windows-gcc-x64",
"compilerPath": "D:/Dev-Cpp/MinGW64/bin/gcc.exe"
}
],
"version": 4
}
点击生成
点击小齿轮,生成默认task.js、launch.js,不需要手动输入