Skip to content

Commit 046193a

Browse files
committed
Fix compiler error in CoreFoundation when building in C++ mode
`__CFAllocatorRespectsHintZeroWhenAllocating` has two declarations in different headers: `ForFoundationOnly.h` and `ForSwiftFoundationOnly.h`. One of the declarations was under `extern "C"` block, the other one wasn't. Clang accepts this in C language mode, but it is a hard compiler error in C++ language mode due to a linkage mismatch. This was blocking clients from using CoreFoundation in Swift projects that enable C++ interoperability. This change makes sure that both declarations of `__CFAllocatorRespectsHintZeroWhenAllocating` are under `extern "C"` blocks.
1 parent 018d8ef commit 046193a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Sources/CoreFoundation/include/ForFoundationOnly.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ CF_EXPORT void *_Nonnull __CFSafelyReallocate(void * _Nullable destination, size
6868
CF_EXPORT void *_Nonnull __CFSafelyReallocateWithAllocator(CFAllocatorRef _Nullable, void * _Nullable destination, size_t newCapacity, CFOptionFlags options, void (^_Nullable reallocationFailureHandler)(void *_Nonnull original, bool *_Nonnull outRecovered));
6969
#endif
7070

71+
_CF_EXPORT_SCOPE_BEGIN
7172
Boolean __CFAllocatorRespectsHintZeroWhenAllocating(CFAllocatorRef _Nullable allocator);
73+
_CF_EXPORT_SCOPE_END
74+
7275
typedef CF_ENUM(CFOptionFlags, _CFAllocatorHint) {
7376
_CFAllocatorHintZeroWhenAllocating = 1
7477
};

0 commit comments

Comments
 (0)