Skip to content

Commit 405d3c6

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 405d3c6

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

ext/charlock_holmes/converter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "unicode/ucnv.h"
22
#include "common.h"
33

4+
extern "C" {
5+
46
extern VALUE rb_mCharlockHolmes;
57
static VALUE rb_cConverter;
68

@@ -55,3 +57,5 @@ void _init_charlock_converter() {
5557

5658
rb_define_singleton_method(rb_cConverter, "convert", rb_converter_convert, 3);
5759
}
60+
61+
}

ext/charlock_holmes/encoding_detector.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include "unicode/ucsdet.h"
22
#include "common.h"
33

4+
extern "C" {
5+
46
extern VALUE rb_mCharlockHolmes;
57
static VALUE rb_cEncodingDetector;
68

@@ -375,3 +377,5 @@ void _init_charlock_encoding_detector()
375377

376378
rb_define_singleton_method(rb_cEncodingDetector, "supported_encodings", rb_get_supported_encodings, 0);
377379
}
380+
381+
}

ext/charlock_holmes/ext.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#include "common.h"
22

3+
extern "C" {
4+
35
extern void _init_charlock_encoding_detector();
46
extern void _init_charlock_converter();
57
extern void _init_charlock_transliterator();
68

79
VALUE rb_mCharlockHolmes;
810

9-
void Init_charlock_holmes() {
11+
__attribute__((visibility ("default"))) void Init_charlock_holmes() {
1012
rb_mCharlockHolmes = rb_define_module("CharlockHolmes");
1113

1214
_init_charlock_encoding_detector();
1315
_init_charlock_converter();
1416
_init_charlock_transliterator();
15-
}
17+
}
18+
19+
}

0 commit comments

Comments
 (0)