vscode c_cpp_properties setting
vscode c_cpp_properties setting
C/C++ 插件用户工程项目配置
.vscode/c_cpp_properties.json 增加如下内容:
{ "version": 4, "configurations": [ { "name": "mingw-w64-x86_64", "intelliSenseMode": "gcc-x64", "defines": [ "DEBUG", "_DEBUG", "_DEBUG_CDB", "UNICODE", "_UNICODE", "_FORTIFY_SOURCE=1", "CHECK_PTHREAD_RETURN_VALUE", "_FILE_OFFSET_BITS=64", "_LARGEFILE64_SOURCE", "LARGEFILE_SOURCE", "__cdecl=__attribute__((__cdecl__))" ], "includePath": [ "${workspaceRoot}\\\\src", "${workspaceRoot}\\\\inc", "C:\\\\msys64\\\\mingw64\\\\include", "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0\\\\backward", "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0", "C:\\\\msys64\\\\mingw64\\\\x86_64-w64-mingw32\\\\include", "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include-fixed", "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include" ], "browse": { "path": [ "${workspaceRoot}\\\\src", "${workspaceRoot}\\\\inc", "C:\\\\msys64\\\\mingw64\\\\include", "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0\\\\backward", "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0", "C:\\\\msys64\\\\mingw64\\\\x86_64-w64-mingw32\\\\include", "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include-fixed", "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include" ], "limitSymbolsToIncludedHeaders": true, "databaseFilename": "" }, "windowsSdkVersion": "10.0.16299.0", "compilerPath": "C:\\\\msys64\\\\mingw64\\\\bin\\\\g++.exe", "cStandard": "c11", "cppStandard": "c++17" } ] }
-----------------------------------
.vscode/launch.json 增加如下内容:
{ "version": "0.2.0", "configurations": [ { "name": "C++ Launch (GDB)", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe", "miDebuggerArgs": "", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
.vscode/tasks.json 增加如下内容:
{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "BuildProject", "command": "C:\\msys64\\msys2_shell.cmd", "args": [ "-mingw64", "-where", "${fileDirname}", "-shell", "bash", "build.sh", "${fileBasenameNoExtension}" ], "options": { "cwd": "C:\\msys64" }, "group": { "kind": "build", "isDefault": true }, "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false }, "problemMatcher": "$gcc" }, { "type": "shell", "label": "CleanProject", "command": "C:\\msys64\\msys2_shell.cmd", "args": [ "-mingw64", "-where", "${fileDirname}", "-shell", "bash", "clean.sh", "${fileBasenameNoExtension}" ], "options": { "cwd": "C:\\msys64" }, "group": { "kind": "test", "isDefault": true }, "presentation": { "echo": true, "reveal": "always", "focus": false, "panel": "shared", "showReuseMessage": true, "clear": false }, "problemMatcher": "$gcc" } ] }
------------------------------------
Code-Runner 插件用户全局配置
C:\Users\LSGX\AppData\Roaming\Code\User\settings.json 增加如下内容:
"code-runner.runInTerminal": true,
"code-runner.ignoreSelection": true,
"code-runner.executorMap": {
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -std=c11 && $dir$fileNameWithoutExt.exe",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -std=c++17 && $dir$fileNameWithoutExt.exe"
}
----------------------------------------
C++ 编译器支持情况表 https://zh.cppreference.com/w/cpp/compiler_support
--------------------------------------
查看 gcc 配置信息 echo | gcc -v -x c -E -
查看 g++ 配置信息 echo | gcc -v -x c++ -E -
查看 g++ 配置信息 echo | g++ -v -x c++ -E -
--------------------------
注意: mingw32 不支持wWinMain作为程序入口,需要将wWinMain改为WinMain 。
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/x86_64-w64-mingw32/lib//libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
via https://stackoverflow.com/questions/58324230/undefined-reference-to-winmain-c-mingw
One thing to note is that Visual C++ supports a “wWinMain” entry point where the “lpCmdLine” parameter is a “LPWSTR”. You would typically use the “_tWinMain” preprocessor definition for your entry point and declare “LPTSTR lpCmdLine” so that you can easily support both ANSI and Unicode builds. However, the MinGW CRT startup library does not support wWinMain, so you’ll have to stick with the standard “WinMain” and use “GetCommandLine()” if you need to access command line arguments.
Use WinMain
instead. This program doesn't use pCmdLine
value, so it should compile when you change wWinMain
to WinMain
and PWSTR pCmdLine
to PSTR pCmdLine
.
via https://docs.microsoft.com/en-us/windows/win32/learnwin32/prepare-your-development-environment
via https://www.transmissionzero.co.uk/computing/win32-apps-with-mingw/
================ End
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
2018-12-30 深入理解Java中的String
2018-12-30 Java中字符串string的数据类型
2018-12-30 IDEA设置JVM运行参数