mirror of
https://github.com/apple/swift-nio
synced 2026-11-22 04:30:41 +00:00
Make CNIOAtomics and CNIODarwin compatible with C++ interop (#3251)
### 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.
Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
1 parent
b23163df5f
commit
adfa636b4b
2 files changed
+16
No files matched your search
@@ -15,6 +15,10 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DECLARE_ATOMIC_OPERATIONS(type, name) \
|
||||
struct catmc_atomic_ ## name; \
|
||||
\
|
||||
@@ -78,3 +82,7 @@ DECLARE_ATOMIC_OPERATIONS(intptr_t, intptr_t)
|
||||
DECLARE_ATOMIC_OPERATIONS(uintptr_t, uintptr_t)
|
||||
|
||||
#undef DECLARE_ATOMIC_OPERATIONS
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
@@ -24,6 +24,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fts.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Darwin platforms do not have a sendmmsg implementation available to them. This C module
|
||||
// provides a shim that implements sendmmsg on top of sendmsg. It also provides a shim for
|
||||
// recvmmsg, but does not actually implement that shim, instantly throwing errors if called.
|
||||
@@ -60,5 +64,9 @@ extern const unsigned long CNIODarwin_IOCTL_VM_SOCKETS_GET_LOCAL_CID;
|
||||
|
||||
const char* CNIODarwin_dirent_dname(struct dirent* ent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif // __APPLE__
|
||||
#endif // C_NIO_DARWIN_H
|
||||
Reference in new issue
Block a user