Skip to content

__CFAllocatorRespectsHintZeroWhenAllocating not consistently declared extern C #5125

Closed
@lhoward

Description

@lhoward

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.

<module-includes>:1:10: note: in file included from <module-includes>:1:
1 | #include "CoreFoundation.h"
  |          `- note: in file included from <module-includes>:1:
2 | 

/opt/swift-6.0.2-RELEASE-ubuntu24.04-aarch64/usr/lib/swift/CoreFoundation/CoreFoundation.h:77:10: note: in file included from /opt/swift-6.0.2-RELEASE-ubuntu24.04-aarch64/usr/lib/swift/CoreFoundation/CoreFoundation.h:77:
 75 | #include "CFConstantKeys.h"
 76 | 
 77 | #include "ForSwiftFoundationOnly.h"
    |          `- note: in file included from /opt/swift-6.0.2-RELEASE-ubuntu24.04-aarch64/usr/lib/swift/CoreFoundation/CoreFoundation.h:77:
 78 | 
 79 | #if TARGET_OS_OSX || TARGET_OS_IPHONE || TARGET_OS_WIN32 || TARGET_OS_LINUX

<unknown>:0: error: could not build C module 'CoreFoundation'
/opt/swift-6.0.2-RELEASE-ubuntu24.04-aarch64/usr/lib/swift/CoreFoundation/ForSwiftFoundationOnly.h:108:20: error: declaration of '__CFAllocatorRespectsHintZeroWhenAllocating' has a different language linkage
106 | _CF_EXPORT_SCOPE_BEGIN
107 | 
108 | CF_PRIVATE Boolean __CFAllocatorRespectsHintZeroWhenAllocating(CFAllocatorRef _Nullable allocator);
    |                    `- error: declaration of '__CFAllocatorRespectsHintZeroWhenAllocating' has a different language linkage
109 | 
110 | struct __CFSwiftObject {

/opt/swift-6.0.2-RELEASE-ubuntu24.04-aarch64/usr/lib/swift/CoreFoundation/ForFoundationOnly.h:71:9: note: previous declaration is here
 69 | #endif
 70 | 
 71 | Boolean __CFAllocatorRespectsHintZeroWhenAllocating(CFAllocatorRef _Nullable allocator);
    |         `- note: previous declaration is here
 72 | typedef CF_ENUM(CFOptionFlags, _CFAllocatorHint) {
 73 |     _CFAllocatorHintZeroWhenAllocating = 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions