使用环境
<!-- 必须 告知插件运行的环境,帮助开发者定位问题 -->
- 操作系统版本:Windows_NT x64 10.0.22631
- 操作系统平台(x86/x64):x64
- VsCode 版本:版本: 1.93.1
- EIDE 插件版本:v3.20.0
- C/C++ 插件版本:未使用,
- 使用的clangd,插件版本:v0.1.29
- clang版本 :18.1.6
- 何种编译器(keil_c51/sdcc/armcc5/armgcc/...):armv6(keil中的v6,应该是clang?)
- 编译器版本(非编译问题可忽略):
描述问题
<!-- 使用简明清晰的语言描述您的问题 -->
使用STM32CubeMX创建的keil v5工程,可以正常编译,但无法跳转函数定义,尝试了Clangd 无法跳转至源文件,只能进入头文件中提到的解决方法并未奏效
我自行添加了如下任务
"afterBuildTasks": [
{
"name": "生成的hex地址",
"disable": false,
"abortAfterFailed": false,
"command": "echo \"firmware: ${OutDir}/${ProjectName}.hex\""
},
{
"name": "添加compile_commands.json",
"disable": false,
"abortAfterFailed": false,
"command": "bash -c \"cp build/${ConfigName}/compile_commands.json build/compile_commands.json\""
},
{
"name": "替换compile_commands.json中的盘符为大写并转换路径分隔符",
"disable": false,
"abortAfterFailed": false,
"command": "bash ./update_compile_commands.sh"
}
],
"global": {
"output-debug-info": "enable"
},
"c/cpp-compiler": {
"optimization": "level-0",
"language-c": "c99",
"language-cpp": "c++14",
"warnings": "ac5-like-warnings"
},
"asm-compiler": {
"$use": "asm-auto"
},
"linker": {
"output-format": "elf",
"misc-controls": "--diag_suppress=L6329"
}
试图进行compile_commands.json文件的生成以及大小写和转义符处理
但是从clangd输出来看,并没有成功大小写转换,
V[01:08:39.150] <<< {
"id": 150,
"jsonrpc": "2.0",
"method": "textDocument/documentHighlight",
"params": {
"position": {
"character": 10,
"line": 103
},
"textDocument": {
"uri": "file:///d%3A/Codes/Project%20ARM/HAL/Development_Boards/DM_MC02/ClangdTest/Src/main.c"
}
}
}
I[01:08:39.150] <-- textDocument/documentHighlight(150)
V[01:08:39.153] ASTWorker running Highlights on version 3 of d:/Codes/Project ARM/HAL/Development_Boards/DM_MC02/ClangdTest/Src/main.c
I[01:08:39.153] --> reply:textDocument/documentHighlight(150) 3 ms
V[01:08:39.153] >>> {
"id": 150,
"jsonrpc": "2.0",
"result": [
{
"kind": 1,
"range": {
"end": {
"character": 13,
"line": 103
},
"start": {
"character": 4,
"line": 103
}
}
}
]
}
I[01:08:39.154] --> textDocument/clangd.fileStatus
V[01:08:39.154] >>> {
"jsonrpc": "2.0",
"method": "textDocument/clangd.fileStatus",
"params": {
"state": "idle",
"uri": "file:///d:/Codes/Project%20ARM/HAL/Development_Boards/DM_MC02/ClangdTest/Src/main.c"
}
}
uri依然是小写,但是compile_commands.json中已经是大写了(等下,会不会是我的路径中包含空格,我明天尝试修改一下),以下是compile_commands.json的一部分
[{"directory":"D:/Codes/Project ARM/HAL/Development_Boards/DM_MC02/ClangdTest","file":"D:/Codes/Project ARM/HAL/Development_Boards/DM_MC02/ClangdTest/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c","command":"\"D:/Keil_v5/ARM/ARMCLANG/bin/armclang.exe\" --target=arm-arm-none-eabi -c -xc -std=c99 -IInc -IDrivers/STM32H7xx_HAL_Driver/Inc -IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy -IDrivers/CMSIS/Device/ST/STM32H7xx/Include -IDrivers/CMSIS/Include -I.cmsis/include -IMDK-ARM/RTE/_ClangdTest -DUSE_HAL_DRIVER -DSTM32H723xx -mfloat-abi=hard -mfpu=fpv5-d16 -mcpu=cortex-m7 -mlittle-endian -O0 -fno-function-sections -funsigned-char -fno-rtti -Wno-packed -Wno-missing-variable-declarations -Wno-missing-prototypes -Wno-missing-noreturn -Wno-sign-conversion -Wno-nonportable-include-path -Wno-reserved-id-macro -Wno-unused-macros -Wno-documentation-unknown-command -Wno-documentation -Wno-license-management -Wno-parentheses-equality -g -o ./build/ClangdTest/.obj/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.o -MMD ./Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c"},
屏幕截图
<!--使用一些截图能够更好地展现问题 -->
强行跳转就得到下图
期望现象
<!--您期望应该产生的,但实际上却没有发生的结果-->
可以跳转到.c文件而不是只能跳转到.h