Skip to content

Conversation

@egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented May 23, 2025

Motivation:

This fixes linker errors such as

@nonobjc __C.catmc_nio_atomic_uint_least32_t_create_with_existing_storage(Swift.UnsafeMutablePointer<__C.catmc_nio_atomic_uint_least32_t>, Swift.UInt32) -> () in NIOAtomic.swift.o
   NOTE: found '_catmc_nio_atomic_uint_least32_t_create_with_existing_storage' in c-nioatomics.c.o, declaration possibly missing 'extern "C"'

when building with Swift/C++ interoperability enabled.

Modifications:

Wrapped the C declarations a couple of headers in extern "C" { ... } blocks.

Result:

The project builds successfully with Swift/C++ interop enabled.

@egorzhdan
Copy link
Contributor Author

The CI failures seem unrelated!

@Lukasa Lukasa added the 🔨 semver/patch No public API change. label May 23, 2025
This fixes linker errors such as
```
@nonobjc __C.catmc_nio_atomic_uint_least32_t_create_with_existing_storage(Swift.UnsafeMutablePointer<__C.catmc_nio_atomic_uint_least32_t>, Swift.UInt32) -> () in NIOAtomic.swift.o
   NOTE: found '_catmc_nio_atomic_uint_least32_t_create_with_existing_storage' in c-nioatomics.c.o, declaration possibly missing 'extern "C"'
```
when building with Swift/C++ interoperability enabled.
@egorzhdan egorzhdan force-pushed the egorzhdan/extern-c branch from 580c6e1 to f2e86fd Compare May 23, 2025 17:04
@Lukasa Lukasa enabled auto-merge (squash) May 23, 2025 17:06
@Lukasa Lukasa merged commit adfa636 into apple:main May 23, 2025
36 of 41 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/extern-c branch May 23, 2025 17:34
Lukasa pushed a commit to apple/swift-nio-ssl that referenced this pull request May 28, 2025
This fixes linker errors such as
```
"CNIOBoringSSLShims_SSL_CTX_get_app_data(CNIOBoringSSL_ssl_ctx_st const*)", referenced from:
      static NIOSSL.NIOSSLContext.(lookupFromRawContext in <...>)(ssl: Swift.OpaquePointer) -> NIOSSL.NIOSSLContext in SSLContext.swift.o
```
when building with Swift/C++ interoperability enabled.

This is similar to apple/swift-nio#3251.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants