JUCE header include guards

Hello,

It looks like there used to be include guards in the headers but this is no longer the case, making it impossible to include the headers actually needed by my interfaces.

Why were these removed?

Thanks

They have been replaced by the more modern #pragma once, which is a specific feature for controlling recursive includes, vs using generic macro’s

Sorry I see that some of the headers have them but many do not, e.g.:

https://github.com/juce-framework/JUCE/blob/master/modules/juce_audio_devices/audio_io/juce_AudioIODevice.h.

I’ll file a bug report

This is no bug, this is intended. JUCE follows the Unity Build scheme and you are only allowed to include the top level module headers, in your example you have to include

#include <juce_audio_devices/juce_audio_devices.h>

By “Unity Build scheme” do you mean merging of translation units in order to reduce compiler parsing?
How does this affect which public headers can/can’t be included by the API user?

That is exactly what @PluginPenguin is referring to. The JUCE framework is designed such that there is usually one (there can be more than one) compilation unit, AND one header per module. You can read more about this here.

1 Like

Thanks, that doc is useful!