Skip to content

Commit

Permalink
Avoid C++ name mangling in C code
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stanhu committed Jul 9, 2024
1 parent 7f026b4 commit 01df9a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 15 additions & 0 deletions ext/charlock_holmes/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,19 @@ static inline VALUE charlock_new_str2(const char *str)
#endif
}


#ifdef __cplusplus
extern "C"
{
#endif

extern void Init_charlock_holmes();
extern void _init_charlock_encoding_detector();
extern void _init_charlock_converter();
extern void _init_charlock_transliterator();

#ifdef __cplusplus
}
#endif

#endif
6 changes: 1 addition & 5 deletions ext/charlock_holmes/ext.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "common.h"

extern void _init_charlock_encoding_detector();
extern void _init_charlock_converter();
extern void _init_charlock_transliterator();

VALUE rb_mCharlockHolmes;

void Init_charlock_holmes() {
Expand All @@ -12,4 +8,4 @@ void Init_charlock_holmes() {
_init_charlock_encoding_detector();
_init_charlock_converter();
_init_charlock_transliterator();
}
}

0 comments on commit 01df9a5

Please sign in to comment.