2026-04-10 1:53 AM
I'm experiencing some issues with indexing of clangd. I'm working on a project including Bluetooth LE and the ble_types.h header file makes extensive use of the preprocessor define __PACKED_STRUCT which is defined in one of the CMSIS compiler header files (e.g., cmsis_gcc.h for GCC compiler). clangd is for some reason not able to resolve the typedefs using __PACKED_STRUCT which makes code browsing harder and auto-completion does not work for these types.
I found a workaround by adding the __PACKED_STRUCT define explicitly in the .clangd config file.
My current .clangd file looks as follows:
CompileFlags:
Add:
- '-ferror-limit=0'
- '-Wno-implicit-int'
- '-D__PACKED_STRUCT=struct __attribute__((packed, aligned(1)))'
CompilationDatabase: build/Debug
Diagnostics:
Suppress:
- unused-includes
- unknown_typename
- unknown_typename_suggest
- typename_requires_specqual
Completion:
HeaderInsertion: NeverSo I basically added the preprocessor define to the CompileFlags. Of course this is not universal now and only valid for GCC. Also any other preprocessor defines would need to be added manually.
I also have automatic header insertion disabled since this caused issues.
I'm wondering if anyone else experiences similar issues and if there is a cleaner way to solve it?
2026-04-14 1:04 AM
unfortunately I'm not able to reproduce could you please attach an example project with the issue you described