Bug #20872
openUndefined RUBY_API_VERSION_* macros used in <ruby/backward/cxxanyargs.hpp>
Description
I just noticed that C++ compilers warn for undefined RUBY_API_VERSION_MAJOR/RUBY_API_VERSION_MINOR macros in <ruby/backward/cxxanyargs.hpp> when preprocessing <ruby.h>.
% cat test.cpp
#include <ruby.h>
% clang++ -Wundef -I ~/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0 -I ~/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/x86_64-linux -c test.cpp -o /dev/null
In file included from test.cpp:1:
In file included from /home/kasumi/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/ruby.h:38:
In file included from /home/kasumi/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/ruby/ruby.h:27:
In file included from /home/kasumi/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/ruby/internal/anyargs.h:83:
/home/kasumi/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/ruby/backward/cxxanyargs.hpp:540:6: warning: 'RUBY_API_VERSION_MAJOR' is not defined, evaluates to 0 [-Wundef]
#if (RUBY_API_VERSION_MAJOR * 100 + RUBY_API_VERSION_MINOR) >= 301
^
/home/kasumi/.rbenv/versions/3.4.0-preview2/include/ruby-3.4.0+0/ruby/backward/cxxanyargs.hpp:540:37: warning: 'RUBY_API_VERSION_MINOR' is not defined, evaluates to 0 [-Wundef]
#if (RUBY_API_VERSION_MAJOR * 100 + RUBY_API_VERSION_MINOR) >= 301
^
2 warnings generated.
The offending code was introduced in 01825e8bffd. The accompanying code comment says a deprecation warning should be emitted for some use-cases (passing ANYARGS function pointers to rb_define_method-series functions) with Ruby 3.x, which looks not working as intended for the current Ruby versions.
This seems effectively doing no harm but just disturbing for extension developers.
Updated by nobu (Nobuyoshi Nakada) almost 2 years ago
It looks no hurt to remove the conditional already.
Updated by hanazuki (Kasumi Hanazuki) almost 2 years ago
nobu (Nobuyoshi Nakada) wrote in #note-1:
It looks no hurt to remove the conditional already.
Ah, yes. That should be right.
Updated by dug (Doug E) 2 days ago
I think this was fixed by https://github.com/ruby/ruby/pull/15843, and can be closed.