`clangd` LSP and JUCE's unity build

Hi,

Like probably a lot of you I’m using clangd in my editor to get live language support (code completion, indexing, error reporting etc.), and Xcode does too AFAIK. But when I browse JUCE’s own code I get include errors everywhere, and jumping to definitions of symbols point to the wrong locations.

That’s obviously because of JUCE modules’ idiosyncratic “unity build” style, i.e. single source files (say, juce_ListenerList.h) are not self contained but meant to be included in the module’s base file (juce_core.h).

AFAICT clangd does not support non-self-contained files, period. Am I missing something or do you (esp. JUCE devs) really live without live error reporting, jump-to-definitions etc. inside of JUCE’s code?

Thanks in advance!

This was just discussed here:

And in multiple other places on the forum. Would be great if the JUCE team would take a look and finally fix that.

Oh thanks, sorry I’ve missed these discussions.
In these threads everyone seems to be having the issue with VS and VSCode; does this means Xcode can see through the unity-build style? If it does, it means there might be a solution to inform clangd.

Xcode, CLion and Visual Studio with Resharper do a much better job, because they also parse the entire build system and not just recursively going through the headers.

That won’t work with a standalone clangd plugin for an editor like VSCode as it’s not aware of the build system so it can’t “see” those other cpp files that implicitly include the header/source you’re looking at now.