Clangd With MinGW 和 VSCode

前往https://github.com/clangd/clangd/releases下载最新的clangd 复制并移动bin/clangd.exe到你想要的位置,添加环境变量。

解决vscode clangd 无法读取到mingw头文件的问题

VScode中Ctrl+Shift+P搜索选项打开设置(JSON),添加

"clangd.fallbackFlags": [      
        "-I你放mingw的地方/mingw64/include"
],

我用的参数

"clangd.arguments": [
        "--header-insertion=iwyu",
        "--all-scopes-completion",
        "--completion-style=detailed",
        "--background-index",
        "-j=4",
        "--fallback-style=webkit"
    ],

参数解释:

头文件自动插入模式 (--header-insertion=iwyu)

全作用域补全 (--all-scopes-completion)


详细补全风格 (--completion-style=detailed)


后台索引 (--background-index)


并行任务数 (-j=4)

设置格式化缩进风格(--fallback-style=webkit)

最好给这个填上,默认的缩进是两格,傻逼的离谱。

© 2026 myfk. All rights reserved.