Skip to content

Commit d525027

Browse files
committed
Add extern "C" to header process_shims.h
Previous, we would encounter missing symbol errors like: "_subprocess_vm_size()", referenced from: closure #1 () -> Swift.Int in variable initialization expression of Subprocess.(_pageSize in _EDE99368FF43462E0C75AF3C9D4D8F2D) : Swift.Int in AsyncBufferSequence.swift.o NOTE: found '__subprocess_vm_size' in process_shims.c.o, declaration possibly missing 'extern "C"' We can reproduce this by running: xcrun swift build -Xswiftc -cxx-interoperability-mode=default --build-tests Adding `extern "C"` fixes these issues. rdar://161624906
1 parent dc3bbd2 commit d525027

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/_SubprocessCShims/include/process_shims.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
#include <sys/wait.h>
3636
#endif // TARGET_OS_LINUX || TARGET_OS_FREEBSD
3737

38+
#ifdef __cplusplus
39+
extern "C" {
40+
#endif
41+
3842
#if __has_include(<mach/vm_page_size.h>)
3943
vm_size_t _subprocess_vm_size(void);
4044
#endif
@@ -102,12 +106,20 @@ int _pidfd_open(pid_t pid);
102106

103107
#endif
104108

109+
#ifdef __cplusplus
110+
} // extern "C"
111+
#endif
112+
105113
#endif // !TARGET_OS_WINDOWS
106114

107115
#if TARGET_OS_WINDOWS
108116

109117
#include <Windows.h>
110118

119+
#ifdef __cplusplus
120+
extern "C" {
121+
#endif
122+
111123
#ifndef _WINDEF_
112124
typedef unsigned long DWORD;
113125
typedef int BOOL;
@@ -122,6 +134,10 @@ unsigned int _subprocess_windows_get_errno(void);
122134
/// complex macro and cannot be imported directly into Swift.
123135
DWORD_PTR _subprocess_PROC_THREAD_ATTRIBUTE_HANDLE_LIST(void);
124136

137+
#ifdef __cplusplus
138+
} // extern "C"
139+
#endif
140+
125141
#endif
126142

127143
#endif /* process_shims_h */

0 commit comments

Comments
 (0)