From 150f514e19125ce8239602dc9266c7f68166d671 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, 9 Sep 2019 11:13:31 +0900 Subject: workaround for C++ 98 const union problem. Not the case of recent compilers, but compilers before C++11 rejected ruby.h, like https://ci.appveyor.com/project/ruby/ruby/builds/27225706/job/qjca7dpe204dytbd This is supposedly because a struct with a member qualified with a const effectively deletes its default copy constructor, which is considered as being user-defined somehow. Not sure where exactly is the phrase in the C++98 standard who allows such C / C++ incompatibility though. --- include/ruby/ruby.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 445b2cd4d3..0bede6ffdd 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -1054,7 +1054,12 @@ struct RArray { long len; union { long capa; - const VALUE shared_root; +#if defined(__clang__) /* <- clang++ is sane */ || \ + !defined(__cplusplus) /* <- C99 is sane */ || \ + (__cplusplus > 199711L) /* <- C++11 is sane */ + const +#endif + VALUE shared_root; } aux; const VALUE *ptr; } heap; -- cgit v1.2.3