Skip to content

Commit f8cfdf6

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 f8cfdf6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/CoreFoundation/include/ForFoundationOnly.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ CF_IMPLICIT_BRIDGING_DISABLED
5757
#include <mach/mach_time.h>
5858
#endif
5959

60+
_CF_EXPORT_SCOPE_BEGIN
61+
6062
#if __BLOCKS__
6163
/* These functions implement standard error handling for reallocation. Their parameters match their unsafe variants (realloc/CFAllocatorReallocate). They differ from reallocf as they provide a chance for you to clean up a buffers contents (in addition to freeing the buffer, etc.)
6264
@@ -69,10 +71,13 @@ CF_EXPORT void *_Nonnull __CFSafelyReallocateWithAllocator(CFAllocatorRef _Nulla
6971
#endif
7072

7173
Boolean __CFAllocatorRespectsHintZeroWhenAllocating(CFAllocatorRef _Nullable allocator);
74+
7275
typedef CF_ENUM(CFOptionFlags, _CFAllocatorHint) {
7376
_CFAllocatorHintZeroWhenAllocating = 1
7477
};
7578

79+
_CF_EXPORT_SCOPE_END
80+
7681
#define NSISARGTYPE void * _Nullable
7782

7883
#pragma mark - CFBundle

0 commit comments

Comments
 (0)