Skip to content

Commit baef1ff

Browse files
authored
Merge pull request #3157 from egorzhdan/egorzhdan/extern-c
Make SwiftSyntaxCShims compatible with C++
2 parents bd7bf0b + 964a4bf commit baef1ff

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

Sources/_SwiftSyntaxCShims/include/Atomics.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#include <stdbool.h>
1717
#include <stdlib.h>
1818

19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
1923
typedef struct {
2024
_Atomic(bool) value;
2125
} AtomicBool;
@@ -50,4 +54,8 @@ static inline void swiftsyntax_atomic_pointer_set(AtomicPointer *_Nonnull atomic
5054
atomic->value = newValue;
5155
}
5256

57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
5361
#endif // SWIFTSYNTAX_ATOMICBOOL_H

Sources/_SwiftSyntaxCShims/include/PlatformMutex.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
#include "_bridging.h"
1717

18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
1822
typedef struct PlatformMutex {
1923
void *opaque;
2024
} PlatformMutex;
@@ -31,4 +35,8 @@ void swiftsyntax_platform_mutex_unlock(PlatformMutex m);
3135
SWIFT_NAME_S("PlatformMutex.destroy(self:)")
3236
void swiftsyntax_platform_mutex_destroy(PlatformMutex m);
3337

38+
#ifdef __cplusplus
39+
}
40+
#endif
41+
3442
#endif // SWIFTSYNTAX_PLATFORMMUTEX_H

Sources/_SwiftSyntaxCShims/include/swiftsyntax_errno.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@
1717

1818
#include <errno.h>
1919

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
2024
SWIFT_NAME_S("getter:swift_syntax_errno()")
2125
static inline int swiftsyntax_errno(void) {
2226
return errno;
2327
}
2428

29+
#ifdef __cplusplus
30+
}
31+
#endif
32+
2533
#endif // SWIFTSYNTAX_ERRNO_H

Sources/_SwiftSyntaxCShims/include/swiftsyntax_stdio.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
#include <stdio.h>
1919

20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
2024
SWIFT_NAME_S("getter:swift_syntax_stdout()")
2125
static inline FILE *swiftsyntax_stdout(void) {
2226
return stdout;
@@ -32,4 +36,8 @@ static inline FILE *swiftsyntax_stderr(void) {
3236
return stderr;
3337
}
3438

39+
#ifdef __cplusplus
40+
}
41+
#endif
42+
3543
#endif // SWIFTSYNTAX_STDIO_H

0 commit comments

Comments
 (0)