TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 227 subscribers
Post #24059 20
Header only library & clangd

Hi there!

In developing a C++ library that is mostly header based, I'm having the most frustrating experience with getting clangd to work properly in VSCode.

Apparently you don't provide a set of include folders (which I'd be happy to), instead you're supposed to rely on clangd's ability to "infer" the build context from cmake's compilecommands.json.

Except clangd invariably gets that part wrong, mixes all up with external dependencies and other branches of my source tree..

What I attempted is to use cmake to generate a cpp file which includes each header in the branch and create an ad'hoc target where I set the correct include paths. The dummy TU, does appear in the compile
commands file, along with the proper include paths, but it looks like that isn't enough.

Had anyone managed to get this right ? I'd be glad to hear about...

Thx.

Edit To clarify : actual compilation is working perfectly fine (according to proper include folders set in the targets), it's just clangd making my life miserable rn by littering my code with a staggering amount of squiggles 😬

https://redd.it/1o6f4ab
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 14, 2026I tested whether a coding agent would use C++23 ranges without being told Blog post: https…
  2. Oct 14, 2026C++ futures part 1: The mental model https://devblogs.microsoft.com/oldnewthing/20261012-0…
  3. Oct 14, 2026C++ futures part 2: The mental model for std::promise, std::packaged_task https://devblogs…
  4. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  5. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  6. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →