[前][次][番号順一覧][スレッド一覧]

ruby-changes:65856

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 13 Apr 2021 14:30:40 +0900 (JST)
Subject: [ruby-changes:65856] f8e1bf283d (master): workaround MSVC error

https://git.ruby-lang.org/ruby.git/commit/?id=f8e1bf283d

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?=
 <shyouhei@r...>
Date: Mon, 12 Apr 2021 11:37:01 +0900
Subject: 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 8ce5234..9432b2e 100644
--- a/include/ruby/internal/core/rdata.h
+++ b/include/ruby/internal/core/rdata.h
@@ -174,14 +174,14 @@ rb_cData(void) https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/core/rdata.h#L174
 
 #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 */
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]