Skip to content

fix(juce): keep the module header includable under using namespace juce - #29

Merged
TobbenTM merged 1 commit into
mainfrom
hise-point-collision-macro-shim
Sep 16, 2026
Merged

TobbenTM merged 1 commit into
mainfrom
hise-point-collision-macro-shim

Conversation

@TobbenTM

@TobbenTM TobbenTM commented Sep 16, 2026

Copy link
Copy Markdown
Member

Including moonbase_licensing.h from a translation unit with a file-scope using namespace juce;, which is how HISE is written, does not compile today: the header-only SDK drags the platform's system headers into the consumer's TU, where Apple's MacTypes.h Point and Windows' wingdi.h Rectangle() become ambiguous with the matching juce names, and MacTypes.h then stops parsing outright. Measured with clang -fsyntax-only against real JUCE 6.1.3 and 8.0.4 trees: 4 errors in both include orders before, 0 after.

The fix renames those system names out of the way around the system includes, using push_macro/pop_macro so a consumer's own Point/Component macros survive, with MOONBASE_DISABLE_SYSTEM_NAME_SHIM to opt out; it is the same trick JUCE uses in juce_audio_devices.cpp. The tradeoff, documented in the JUCE module guide, is that Carbon's Point and GDI's Rectangle() are no longer reachable under their own names in a TU that includes the module header.

tests/juce/global_using_namespace_juce.cpp joins the existing JUCE test target so every CI platform and supported JUCE version compiles this shape; no other TU in the repo has a global using namespace juce;, so CI could not see this class of bug.

@argos-ci

argos-ci Bot commented Sep 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Sep 16, 2026, 9:04 AM

…uce`

The SDK is header-only, so including moonbase_licensing.h drags the platform's
system headers into the consumer's TU. On Apple those reach MacTypes.h and its
global `Point`; on Windows, wingdi.h and its global `Rectangle()`. In a TU with a
file-scope `using namespace juce;`, which is how HISE is written, each becomes
ambiguous with the matching juce name, and MacTypes.h then stops parsing
outright. Measured with clang against JUCE 6.1.3 and 8.0.4: 4 errors either way,
in both include orders.

Rename those system names out of the way around the system includes, with
push_macro/pop_macro so a consumer's own Point/Component macros survive, and
MOONBASE_DISABLE_SYSTEM_NAME_SHIM to opt out. This is the same trick JUCE uses in
juce_audio_devices.cpp.

Add tests/juce/global_using_namespace_juce.cpp to the existing JUCE test target:
no other TU in this repo has a global `using namespace juce;`, so CI could not
see this class of bug at all.
@TobbenTM
TobbenTM force-pushed the hise-point-collision-macro-shim branch from fcca908 to b6fb733 Compare September 16, 2026 09:01
@TobbenTM
TobbenTM merged commit a126bd4 into main Sep 16, 2026
20 checks passed
github-actions Bot pushed a commit that referenced this pull request Sep 16, 2026
## [4.3.1](v4.3.0...v4.3.1) (2026-09-16)

### Bug Fixes

* **juce:** keep the module header includable under `using namespace juce` ([#29](#29)) ([a126bd4](a126bd4))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.3.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant