From f8e1bf283d328dda6334ecca5170b72b870f0da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Mon, 12 Apr 2021 11:37:01 +0900 Subject: [PATCH] workaround MSVC error Previous code failed to compile on MSVC. Log: https://github.com/ruby/ruby/pull/4371/checks?check_run_id=2304484466 This is possibly due to the fact that: 1. `Data_Wrap_Struct(...)` appears in a source code 2. which expands to `rb_data_object_wrap(...)` 3. which expands to `RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING)` 4. which expands to `rb_data_object_wrap_0` 5. which expands to `rb_data_object_wrap`, so far so good, but 6. this is a recursive macro expansion (see step 2). Everybody stops expanding... - in step 4 for MSVC, and - in step 5 for GCC etc. I have no idea why but this proposed changeset prevents MSVC from stopping at step 4. --- include/ruby/internal/core/rdata.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/ruby/internal/core/rdata.h b/include/ruby/internal/core/rdata.h index 8ce5234571..9432b2ed7a 100644 --- a/include/ruby/internal/core/rdata.h +++ b/include/ruby/internal/core/rdata.h @@ -174,14 +174,14 @@ rb_cData(void) #define rb_data_object_wrap_0 rb_data_object_wrap #define rb_data_object_wrap_1 rb_data_object_wrap_warning -#define rb_data_object_wrap_ rb_data_object_wrap_ /* Used here vvvv */ -#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_, RUBY_UNTYPED_DATA_WARNING) +#define rb_data_object_wrap_2 rb_data_object_wrap_ /* Used here vvvv */ +#define rb_data_object_wrap RUBY_MACRO_SELECT(rb_data_object_wrap_2, RUBY_UNTYPED_DATA_WARNING) #define rb_data_object_get_0 rb_data_object_get #define rb_data_object_get_1 rb_data_object_get_warning -#define rb_data_object_get_ rb_data_object_get_ /* Used here vvvv */ -#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_, RUBY_UNTYPED_DATA_WARNING) +#define rb_data_object_get_2 rb_data_object_get_ /* Used here vvvv */ +#define rb_data_object_get RUBY_MACRO_SELECT(rb_data_object_get_2, RUBY_UNTYPED_DATA_WARNING) #define rb_data_object_make_0 rb_data_object_make #define rb_data_object_make_1 rb_data_object_make_warning -#define rb_data_object_make_ rb_data_object_make_ /* Used here vvvv */ -#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_, RUBY_UNTYPED_DATA_WARNING) +#define rb_data_object_make_2 rb_data_object_make_ /* Used here vvvv */ +#define rb_data_object_make RUBY_MACRO_SELECT(rb_data_object_make_2, RUBY_UNTYPED_DATA_WARNING) #endif /* RBIMPL_RDATA_H */