Closed lhoward closed 3 weeks ago
Hmm, still seeing this when adding CF_PRIVATE
to ForFoundationOnly.h for reasons I haven't yet determined (although if CF_PRIVATE
is already defined, ForSwiftFoundationOnly.h won't define it, so that could be it).
Is there a reason it needs to be in ForFoundationOnly.h?
It is there for historical reasons. We can move it to CFInternal.h
and make it CF_PRIVATE
.
@lhoward are you saying this is new to 6.0.2 (vs 6.0)?
@lhoward are you saying this is new to 6.0.2 (vs 6.0)?
I am, although it doesn't really make sense (given the prototype in ForFoundationOnly.h was committed in 2021). I'll try to find out the real reason.
Edit: seeing this on 6.0 as well now.
I can't easily explain why it's just started happening with one particular package I'm trying to build.
But from first principles it seems that this always should have raised an error:
CF_PRIVATE
, if undefined, to extern __attribute__((__visibility__("hidden")))
__CFAllocatorRespectsHintZeroWhenAllocating()
without CF_PRIVATE
__CFAllocatorRespectsHintZeroWhenAllocating()
) with CF_PRIVATE
The only reasons I can think of as to why this didn't raise an error by default:
CF_PRIVATE
was being defined to the empty string (seems unlikely)Actually, it's nothing to do with the visibility attribute. The issue is that __CFAllocatorRespectsHintZeroWhenAllocating
in ForFoundationOnly.h is not within extern "C"
(via _CF_EXPORT_SCOPE_BEGIN
).
Moving __CFAllocatorRespectsHintZeroWhenAllocating
after _CF_EXPORT_SCOPE_BEGIN
in ForFoundationOnly.h also fixes it. Of course #5126 looks like a better fix.
Why did I only see this now? Perhaps it was there all along since Swift 6 and something has changed WRT C++ interoperability (which I am using)?
It makes sense that this could have started in 6.0 vs 6.0.2. Thanks for the investigation.
Tangential: __CFSafelyReallocate()
and __CFSafelyReallocateWithAllocator()
are also declare with incorrect (but not conflicting) linkage when imported as C++. Suggest wrapping them in _CF_EXPORT_SCOPE_BEGIN/END
.
Let's file a new bug/get a new PR for reallocate ones.
when ForFoundationOnly.h and ForSwiftFoundationOnly.h end up being imported, compile fails due to different linkage of
__CFAllocatorRespectsHintZeroWhenAllocating()
.suggest removing it from ForFoundationOnly.h or adding
CF_PRIVATE
.