Skip to content

fix(unreal): macOS build failure — Nil macro collision with Objective-C++#4712

Open
brougkr wants to merge 1 commit intoclockworklabs:masterfrom
brougkr:fix/unreal-macos-nil-macro-collision
Open

fix(unreal): macOS build failure — Nil macro collision with Objective-C++#4712
brougkr wants to merge 1 commit intoclockworklabs:masterfrom
brougkr:fix/unreal-macos-nil-macro-collision

Conversation

@brougkr
Copy link
Copy Markdown
Contributor

@brougkr brougkr commented Mar 26, 2026

Summary

On macOS/Apple platforms, Objective-C++ defines Nil as a macro (#define Nil nullptr in objc/objc.h). Unreal Engine compiles all C++ as Objective-C++ on Apple platforms, so FSpacetimeDBUuid::Nil() in Builtins.h collides with this macro and produces:

error: expected member name or ';' after declaration specifiers; 'nullptr' is a keyword in Objective-C++

Every UE project using the SpacetimeDB Unreal SDK on macOS hits this build failure.

Affected platforms

  • macOS (any version) — Unreal Engine 5.x compiles as Objective-C++ on Apple platforms
  • Affects all SpacetimeDB Unreal SDK versions that expose FSpacetimeDBUuid::Nil()

Reproduction steps

  1. Create or open any Unreal Engine project on macOS
  2. Add the SpacetimeDB Unreal SDK (v2.1.0)
  3. Build the project
  4. Observe the build failure in Builtins.h at FSpacetimeDBUuid::Nil()

Fix

Added #pragma push_macro / #undef Nil / #pragma pop_macro guards in Builtins.h:

  • Before struct definitions: Save and undefine the Nil macro so it doesn't interfere with FSpacetimeDBUuid::Nil() and any other identifiers using Nil
  • After the last closing brace: Restore the original Nil macro so downstream Objective-C++ translation units are unaffected

This is the standard UE pattern for handling platform macro collisions (similar to how UE itself handles check, verify, TEXT, etc. macro conflicts).

Test plan

  • Verify macOS UE build succeeds with the SDK included
  • Verify Windows/Linux builds are unaffected (the #ifdef Nil guard is a no-op when the macro is not defined)
  • Verify FSpacetimeDBUuid::Nil() and NilUuid() Blueprint functions work correctly at runtime

🤖 Generated with Claude Code

…-C++

On macOS/Apple platforms, Objective-C++ defines `Nil` as a macro
(`#define Nil nullptr` in `objc/objc.h`). Unreal Engine compiles as
Objective-C++ on these platforms, so `FSpacetimeDBUuid::Nil()` in
`Builtins.h` collides with the macro and produces:

  error: expected member name or ';' after declaration specifiers;
  'nullptr' is a keyword in Objective-C++

This adds `#pragma push_macro` / `#undef Nil` / `#pragma pop_macro`
guards so the identifier is safe within the header, while restoring
the original macro definition for downstream translation units.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant