Stop ultralib's __assert declaration colliding with Darwin's macro - #419
Open
buddingmonkey wants to merge 1 commit into
Open
Stop ultralib's __assert declaration colliding with Darwin's macro#419buddingmonkey wants to merge 1 commit into
buddingmonkey wants to merge 1 commit into
Conversation
buddingmonkey
force-pushed
the
lh/darwin-assert-collision
branch
from
August 6, 2026 15:57
389aa94 to
6c0efc6
Compare
Apple's <assert.h> defines __assert as a three-argument function-like macro, so ultralib's own declaration of it expanded mid-declaration and the parse collapsed. The declaration sits in the !NDEBUG branch, so Release builds never reached it and only Debug broke -- which is what Xcode's default scheme builds. This is not iOS-specific: a macOS Debug build fails the same way today. Declare it only where the platform has not already provided it. The macro's argument order matches the calls in the file, so on Apple platforms assert() now routes through __assert_rtn.
buddingmonkey
force-pushed
the
lh/darwin-assert-collision
branch
from
August 6, 2026 16:24
6c0efc6 to
bba1cab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
Apple's
<assert.h>already provides__assert, but as a three-argumentfunction-like macro, not a function:
lib/ultralib/include/ultra_assert.hdeclares its own:On Apple platforms the macro expands mid-declaration and the parse collapses,
taking the rest of the header down with it.
Why this hasn't been noticed
The declaration lives in the
#else(i.e.!NDEBUG) branch of the header.Release builds define
NDEBUG, take the#define assert(EX) ((void)0)branchabove, and never reach the declaration. Only Debug builds break.
The fix
Declare
__assertonly where the platform has not already provided it:The macro's argument order (
expression, file, line) matches the call sitesfurther down this same header, so where the platform supplies
__assertwe letit handle the failure — on Apple platforms
assert()now routes through__assert_rtn. Behaviour on every other platform is unchanged: nothing elsedefines
__assertas a macro, so the declaration is emitted exactly as before.One file, ten added lines (eight of which are the explanatory comment).
Notes
Not covered by
run-clang-format.sh(which only formatssrc/port), so noformatting gate applies here — confirmed by running the script and seeing the
tree stay clean apart from this change.
Prepared with AI assistance; the change and its rationale were verified by hand.