Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Sources/_SubprocessCShims/include/process_shims.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include <sys/wait.h>
#endif // TARGET_OS_LINUX || TARGET_OS_FREEBSD

#ifdef __cplusplus
extern "C" {
#endif

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would be better served with a:

extern "C" {

block rather than annotating each of the declarations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I originally had, and then I saw #include <Windows.h> and realized I couldn't just wrap the entire thing with extern "C".

... But on second thought, I could just hoist that up to the top, and do the extern "C" thing you suggest (which is a cleaner patch).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, as long as the includes come outside of the block, it is simpler. That also avoids the pitfall of missing the annotation on a future declaration.

#if __has_include(<mach/vm_page_size.h>)
vm_size_t _subprocess_vm_size(void);
#endif
Expand Down Expand Up @@ -102,12 +106,20 @@ int _pidfd_open(pid_t pid);

#endif

#ifdef __cplusplus
} // extern "C"
#endif

#endif // !TARGET_OS_WINDOWS

#if TARGET_OS_WINDOWS

#include <Windows.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifndef _WINDEF_
typedef unsigned long DWORD;
typedef int BOOL;
Expand All @@ -122,6 +134,10 @@ unsigned int _subprocess_windows_get_errno(void);
/// complex macro and cannot be imported directly into Swift.
DWORD_PTR _subprocess_PROC_THREAD_ATTRIBUTE_HANDLE_LIST(void);

#ifdef __cplusplus
} // extern "C"
#endif

#endif

#endif /* process_shims_h */