Skip to content

Commit 01df9a5

Browse files
committed
Avoid C++ name mangling in C code
Now that a C++ compiler is used to support later versions of ICU, we need to surround all C code with `extern "C"` to avoid name mangling that would cause issues with symbol resolution on macOS.
1 parent 7f026b4 commit 01df9a5

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

ext/charlock_holmes/common.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,19 @@ static inline VALUE charlock_new_str2(const char *str)
3838
#endif
3939
}
4040

41+
42+
#ifdef __cplusplus
43+
extern "C"
44+
{
45+
#endif
46+
47+
extern void Init_charlock_holmes();
48+
extern void _init_charlock_encoding_detector();
49+
extern void _init_charlock_converter();
50+
extern void _init_charlock_transliterator();
51+
52+
#ifdef __cplusplus
53+
}
54+
#endif
55+
4156
#endif

ext/charlock_holmes/ext.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
#include "common.h"
22

3-
extern void _init_charlock_encoding_detector();
4-
extern void _init_charlock_converter();
5-
extern void _init_charlock_transliterator();
6-
73
VALUE rb_mCharlockHolmes;
84

95
void Init_charlock_holmes() {
@@ -12,4 +8,4 @@ void Init_charlock_holmes() {
128
_init_charlock_encoding_detector();
139
_init_charlock_converter();
1410
_init_charlock_transliterator();
15-
}
11+
}

0 commit comments

Comments
 (0)