当前位置: 首页 > news >正文

VSCode、clangd、mingw 配置与使用

1.安装

安装如下软件:

  • VSCode
  • clangd 扩展
  • mingw-w64

2.配置

配置好 mingw-w64 到用户环境中。

在项目中设置 .clangd 扩展,设置 argument

//setting.json

    "clangd.arguments": [
        "--query-driver=D:\\Development\\Tools\\mingw64\\bin\\gcc.exe"
    ]

在这里插入图片描述

然后创建 .clangd 文件进行配置,内容如下

CompileFlags:
  Compiler: gcc.exe

3.结果

clangd 成功解析

在这里插入图片描述

clangd log

I[16:27:25.990] <-- shutdown(25)
I[16:27:25.990] --> reply:shutdown(25) 0 ms
I[16:27:25.991] <-- exit
I[16:27:25.991] LSP finished, exiting with status 0
I[16:27:26.112] clangd version 20.1.0 (https://github.com/llvm/llvm-project 24a30daaa559829ad079f2ff7f73eb4e18095f88)
I[16:27:26.113] Features: windows+grpc
I[16:27:26.113] PID: 17468
I[16:27:26.113] Working directory: d:\Development\Projects\VSCodeProjects\learnC
I[16:27:26.113] argv[0]: D:\Development\Tools\clangd_20.1.0\bin\clangd.exe
I[16:27:26.113] argv[1]: --query-driver=D:\Development\Tools\mingw64\bin\gcc.exe
I[16:27:26.122] Starting LSP over stdin/stdout
I[16:27:26.122] <-- initialize(0)
I[16:27:26.135] --> reply:initialize(0) 12 ms
I[16:27:26.136] <-- initialized
I[16:27:26.140] <-- textDocument/didOpen
E[16:27:26.151] System include extraction: driver clang not found in PATH
I[16:27:26.152] <-- textDocument/documentSymbol(1)
I[16:27:26.154] --> textDocument/publishDiagnostics
I[16:27:26.156] <-- textDocument/documentLink(2)
I[16:27:26.156] Failed to find compilation database for d:\Development\Projects\VSCodeProjects\learnC\w3schools\test.c
I[16:27:26.163] <-- textDocument/inlayHint(3)
I[16:27:26.322] System includes extractor: successfully executed D:\Development\Tools\mingw64\bin\gcc.exe
	got includes: "D:/Development/Tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed, D:/Development/Tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include"
	got target: "x86_64-w64-mingw32"
I[16:27:26.323] ASTWorker building file d:\Development\Projects\VSCodeProjects\learnC\w3schools\test.c version 1 with command clangd fallback
[d:\Development\Projects\VSCodeProjects\learnC\w3schools]
"D:\\Development\\Tools\\mingw64\\bin\\gcc.exe" -isystem D:/Development/Tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/include-fixed -isystem D:/Development/Tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/include --target=x86_64-w64-mingw32 "-resource-dir=D:\\Development\\Tools\\clangd_20.1.0\\lib\\clang\\20" -- "d:\\Development\\Projects\\VSCodeProjects\\learnC\\w3schools\\test.c"
I[16:27:26.326] --> textDocument/clangd.fileStatus
I[16:27:26.351] <-- textDocument/foldingRange(4)
I[16:27:26.351] --> reply:textDocument/foldingRange(4) 0 ms
I[16:27:26.362] Built preamble of size 460200 for file d:\Development\Projects\VSCodeProjects\learnC\w3schools\test.c version 1 in 0.04 seconds
I[16:27:26.363] --> workspace/semanticTokens/refresh(0)
I[16:27:26.363] Indexing c17 standard library in the context of d:\Development\Projects\VSCodeProjects\learnC\w3schools\test.c
I[16:27:26.364] <-- reply(0)
I[16:27:26.365] <-- textDocument/semanticTokens/full(5)
I[16:27:26.381] --> textDocument/publishDiagnostics
I[16:27:26.381] --> textDocument/inactiveRegions
I[16:27:26.382] --> reply:textDocument/documentSymbol(1) 230 ms
I[16:27:26.382] --> reply:textDocument/documentLink(2) 225 ms
I[16:27:26.382] --> reply:textDocument/inlayHint(3) 218 ms
I[16:27:26.382] --> reply:textDocument/semanticTokens/full(5) 17 ms
I[16:27:26.382] --> textDocument/clangd.fileStatus
I[16:27:26.476] Indexed c17 standard library: 2683 symbols, 2 filtered

相关文章:

  • 数据结构篇:线性表的另一表达—链表之单链表(上篇)
  • 地理数据输出
  • 解决缓存穿透的布隆过滤器与布谷鸟过滤器:谁更适合你的应用场景?
  • dify文本生成图片
  • 在Ubuntu系统如何让MySQL服务器支持远程连接
  • Elucidating the Design Space of Diffusion-Based Generative Models
  • 【Pandas】pandas DataFrame bool
  • 人工智能与认知科学的交汇:机器是否能“理解”?
  • 【Springboot知识】Springboot进阶-Micrometer指标监控深入解析
  • wsl中迁移ubuntu24.04后docker后无法启动的问题
  • 聊一聊接口测试时需要注意哪些
  • FPAG_BUFFER学习
  • Elasticsearch入门指南(一)
  • zsh: command not found - 鸿蒙 HarmonyOS Next
  • Java 中 JSON 处理库将对象含二进制数组转换为 JSON 字符串
  • ROS2——foxy apt打包离线安装deb包
  • YOLOv11训练中精准率召回率与mAP@0.5的动态变化分析
  • 配置与管理代理服务器
  • openEuler-22.03-LTS-SP3 编译安装 Greenplum-db 6.20.0
  • 【检测手机有无网络】
  • 建站之星导出网站/北京seo
  • 微信团购群网站怎样做/重庆电子商务网站seo
  • wordpress 目录层级/seo排名点击 seo查询
  • 亚马逊品牌备案网站怎么做/网站目录扫描
  • 日本 男女做网站/友情链接也称为
  • 学院网站建设新闻简报/微信引流获客软件