C/C++ 扩展智能提示太慢或无法解析项目

问题

C/C++ 扩展不解析项目,导致源码中的变量、函数都为灰色状态,无法进行跳转。

有时候 log 会报如下错误:

Attempting to get defaults from C++ compiler in "compilerPath" property: 'D:/Development/Tools/mingw64/bin/gcc.exe'
Compiler info database not connected - skipping load.
Compiler query command line: D:/Development/Tools/mingw64/bin/gcc.exe -mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -fdiagnostics-color=always -fdiagnostics-color=always -ffunction-sections -fdata-sections -gdwarf-4 -ggdb -mdisable-hardware-atomics -Og -fno-shrink-wrap -fmacro-prefix-map=D:/Development/Workspace/esp32_workspace/xiaozhi-esp32=. -fmacro-prefix-map=C:/Users/ShiinaKaze/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -m64 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to 32-bit intelliSenseMode.
Compiler query command line: D:/Development/Tools/mingw64/bin/gcc.exe -mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -fdiagnostics-color=always -fdiagnostics-color=always -ffunction-sections -fdata-sections -gdwarf-4 -ggdb -mdisable-hardware-atomics -Og -fno-shrink-wrap -fmacro-prefix-map=D:/Development/Workspace/esp32_workspace/xiaozhi-esp32=. -fmacro-prefix-map=C:/Users/ShiinaKaze/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -m32 -Wp,-v -E -dM -x c nul
Failed to query compiler. Falling back to no bitness.
Compiler query command line: D:/Development/Tools/mingw64/bin/gcc.exe -mlongcalls -fno-builtin-memcpy -fno-builtin-memset -fno-builtin-bzero -fno-builtin-stpcpy -fno-builtin-strncpy -fdiagnostics-color=always -fdiagnostics-color=always -ffunction-sections -fdata-sections -gdwarf-4 -ggdb -mdisable-hardware-atomics -Og -fno-shrink-wrap -fmacro-prefix-map=D:/Development/Workspace/esp32_workspace/xiaozhi-esp32=. -fmacro-prefix-map=C:/Users/ShiinaKaze/esp/v5.4/esp-idf=/IDF -fstrict-volatile-bitfields -fno-jump-tables -fno-tree-switch-conversion -std=gnu17 -Wp,-v -E -dM -x c nul
[01m[Kgcc.exe:[m[K [01;31m[Kerror: [m[Kunrecognized command-line option '[01m[K-mlongcalls[m[K'
[01m[Kgcc.exe:[m[K [01;31m[Kerror: [m[Kunrecognized command-line option '[01m[K-mdisable-hardware-atomics[m[K'

原因

C/C++ 扩展用的语言服务器就是 clangd 的魔改,clangd 会先读取配置,然后再建立索引,这个过程需要一段时间。

如果右下角 language status 没有反应,前往 C/C++ 扩展的设置,将 logging level 调整为 debug 模式,方便查看 C/C++ 扩展运行情况。

在这里插入图片描述
c_cpp_properties.json 是一个很重要的文件,用于配置 C/C++ 扩展,所以按照要求填写,例如 ESP IDF 扩展自动生成的配置文件:

{
  "configurations": [
    {
      "name": "ESP-IDF",
      "compilerPath": "${config:idf.toolsPathWin}\\tools\\xtensa-esp-elf\\esp-14.2.0_20241119\\xtensa-esp-elf\\bin\\xtensa-esp32s3-elf-gcc.exe",
      "compileCommands": "${config:idf.buildPath}/compile_commands.json",
      "includePath": [
        "${config:idf.espIdfPath}/components/**",
        "${config:idf.espIdfPathWin}/components/**",
        "${workspaceFolder}/**"
      ],
      "browse": {
        "path": [
          "${config:idf.espIdfPath}/components",
          "${config:idf.espIdfPathWin}/components",
          "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
      }
    }
  ],
  "version": 4
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值