clangd inferring compile command from wrong source file, how do i override it? - Stack Overflow

I use vscode with the clangd extension. My project builds with CMake and generates a compile_commands.j

I use vscode with the clangd extension. My project builds with CMake and generates a compile_commands.json file in the build directory, which I symlink to the project's root directory. All of that works fine.

However, I am cursed with a plague of red squiggles because clangd guesses incorrectly which command in the compilation database to use when processing my header files.

My project is configured to use Catch2 as a test harness, which is pulled at configure time. Clangd ends up associating my project's header files with Catch2's source files!

For my project's config.hpp header, here is the relevant output from clangd's log:

I[09:36:55.590] ASTWorker building file /home/eniebler/Code/xyzzy/include/xyzzy/detail/config.hpp version
1 with command inferred from /home/eniebler/Code/xyzzy/build/Clang-21.0.0-x86_64/Debug/_deps/catch2-src/
src/catch2/benchmark/detail/catch_analyse.cpp

I understand clangd's heuritics for picking a compile command for a header are imperfect. That's fine, but then I need a way to override the heuristic and tell clangd which source file to use for a header or set of headers.

Or I need clangd to ignore source files in the build directory, or under the _deps directory where CMake's FetchContent puts dependencies.

But I can't find clangd configure options for any of that. Have I overlooked something?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745115819a4612121.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信