Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Clangd Project GeneratorNew to Visual Studio Code? Get it now.
Clangd Project Generator

Clangd Project Generator

魏 少鹏

|
13 installs
| (0) | Free
为当前 VS Code 工作区生成 clangd 项目配置文件。
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Clangd Project Generator Logo

Clangd Project Generator

使用说明

在 VS Code 中打开工程文件夹后,点击状态栏 Clangd 配置,或执行命令:

Clangd Generator: Clangd: Generate Project Files

插件根据当前设置生成 clangd 所需文件:

  • compile_commands.json
  • .clangd(可选)
  • clangd_auto_prototypes.h(可选)

输入方式

  • Use Makefile Dry Run 未启用:递归扫描当前工作区,按 Exclude Dirs 排除指定目录。
  • Use Makefile Dry Run 启用:执行 Makefile dry-run,从构建输出中提取实际参与构建的 .c 文件、包含目录和宏定义。

设置说明

在 VS Code 设置中搜索 Clangd Project Generator。所有设置均不预置工程相关值,请按当前项目需要填写。

  • Compiler Path:用于生成 compile_commands.json 的编译器可执行程序名称或路径。
  • Extra Include Dirs:额外包含目录。相对路径以工作区根目录解析。
  • Defines:额外预处理宏定义,不需要填写 -D。
  • Extra Flags:额外编译参数。
  • Exclude Dirs:递归扫描模式下需要排除的目录名称。
  • Generate Auto Prototypes:生成可选的 clangd_auto_prototypes.h,用于需要补充跨文件声明的工程。
  • Generate Clangd Config:生成 .clangd 文件。
  • Suppress Diagnostics:在生成的 .clangd 中隐藏诊断信息。
  • Enable Inlay Hints:在生成的 .clangd 中启用 clangd 内联提示。
  • Restart Clangd After Generate:生成完成后尝试重启已安装的 clangd VS Code 扩展。

Makefile Dry Run 设置

  • Use Makefile Dry Run:启用或关闭 Makefile dry-run 输入模式。
  • Makefile Path:Makefile 路径,可使用相对工作区根目录的路径或绝对路径。
  • Make Working Directory:执行 dry-run 时的工作目录;留空时使用 Makefile 所在目录。
  • Make Command:执行 Makefile 的 make 可执行程序名称或路径。
  • Make Args:传递给 make 的额外参数、变量或构建目标。插件会自动添加 -n -f <Makefile>。
  • Makefile Names:当 Makefile Path 未填写时,在工作区根目录按顺序查找的 Makefile 文件名。

Makefile dry-run 模式下,如果 Makefile、Make Command 或构建参数无法产生可解析的 .c 编译输入,插件会直接提示错误,不会自动切换为递归扫描。

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft