放结论,三种编译环境易用性上:VS Code > Code::Blocks > Dev-C++。Dev-C++ 不支持自动生成的变量查看。Code::Blocks 不支持单文件编译。
VS Code
安装
官网下载,安装 VS Code,mingw
其中 mingw 有 setup 版本的可以一键配置好
编译调试环境配置
在项目根目录下添加以下配置文件:
.vscode\c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
"cStandard": "gnu17",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64",
"compilerArgs": []
}
],
"version": 4
}
.vscode\launch.json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.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:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "task g++"
}
]
}
.vscode\settings.json
{
"files.associations": {
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"ostream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"tuple": "cpp",
"map": "cpp",
"set": "cpp",
"array": "cpp",
"deque": "cpp",
"string": "cpp",
"vector": "cpp",
"optional": "cpp",
"fstream": "cpp",
"algorithm": "cpp",
"cerrno": "cpp",
"climits": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"memory": "cpp",
"queue": "cpp",
"sstream": "cpp",
"stack": "cpp",
"utility": "cpp",
"list": "cpp",
"rope": "cpp",
"functional": "cpp",
"chrono": "cpp",
"random": "cpp",
"atomic": "cpp",
"bitset": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"cinttypes": "cpp",
"codecvt": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cuchar": "cpp",
"forward_list": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"iterator": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"ratio": "cpp",
"regex": "cpp",
"hash_map": "cpp",
"future": "cpp",
"iomanip": "cpp",
"mutex": "cpp",
"scoped_allocator": "cpp",
"shared_mutex": "cpp",
"thread": "cpp",
"typeindex": "cpp",
"valarray": "cpp",
"stdbool.h": "c",
"stdint.h": "c"
}
}
.vscode\tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "task g++",
"type": "shell",
"command": "D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\Program Files\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
Dev-C++
调试环境配置
工具栏 -> Tools -> Compiler Options -> settings -> Linker -> Generate debugging information (-g3):Yes
ps. Dev-C++ 查看变量只能一个个手动添加
Code::Blocks
项目环境配置
工具栏 -> File -> New -> Project… -> Console application -> C++ -> 项目名称 -> 默认编译器 -> Finish
每要编写一个 C++ 程序,就新建一个 .cpp 文件,编译时复制粘贴到 main.cpp 编译调试运行
ps. Code::Blocks 不支持单文件编译
编写环境配置
工具栏 -> Settings -> Editor -> Code Completion -> 能开则开
调试环境配置
工具栏 -> Settings -> Debugger -> Default:
- Disable startup scripts (-nx) (GDB only)
取消勾选此项后,STL 的变量可以在调试时被正常观察