Skip to content

Commit 767fc92

Browse files
committed
Add a general comment for #undef usages in ruby.c
1 parent e962fa8 commit 767fc92

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/c/cext/ruby.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
#include <fcntl.h>
2727
#include <printf.h>
2828

29+
/*
30+
* Note that some functions are #undef'd just before declaration.
31+
* This is needed because these functions are declared by MRI as macros in e.g., ruby.h,
32+
* and so would produce invalid syntax when using the function name for definition.
33+
*/
34+
2935
void* rb_tr_cext;
3036

3137
#ifdef __APPLE__
@@ -1289,7 +1295,6 @@ bool rb_tr_hidden_p(VALUE value) {
12891295
return false;
12901296
}
12911297

1292-
// Undef conflicting macro from encoding.h like MRI
12931298
#undef rb_enc_str_new
12941299
VALUE rb_enc_str_new(const char *ptr, long len, rb_encoding *enc) {
12951300
return RUBY_INVOKE(rb_str_new(ptr, len), "force_encoding", rb_enc_from_encoding(enc));

0 commit comments

Comments
 (0)