|
Ruby 4.0.5p0 (2026-05-20 revision 64336ffd0ee9e1f4c05891695a3d7b49cb709721)
|
Function overloads to issue warnings around ANYARGS. More...
#include "ruby/internal/attr/maybe_unused.h"#include "ruby/internal/attr/nonnull.h"#include "ruby/internal/attr/weakref.h"#include "ruby/internal/cast.h"#include "ruby/internal/config.h"#include "ruby/internal/has/attribute.h"#include "ruby/internal/intern/class.h"#include "ruby/internal/intern/vm.h"#include "ruby/internal/method.h"#include "ruby/internal/value.h"#include "ruby/backward/2/stdarg.h"#include "ruby/backward/cxxanyargs.hpp"Go to the source code of this file.
Macros | |
| #define | RUBY_METHOD_FUNC(func) |
| This macro is to properly cast a function parameter of *_define_method family. | |
Function overloads to issue warnings around ANYARGS.
For instance rb_define_method takes a pointer to ANYARGS -ed functions, which in fact varies 18 different prototypes. We still need to preserve ANYARGS for storages but why not check the consistencies if possible. With those complex macro overlays defined in this header file, use of a function pointer gets checked against the corresponding arity argument.
Q: What is this __transparent_union__ thing?
A: That is another kind of function overloading mechanism that GCC provides. In this case the attributed function pointer is either VALUE(*)(int,VALUE*,VALUE) or VALUE(*)(int,const VALUE*,VALUE).
This is better than void* or ANYARGS because we can reject all other possibilities than the two.
Definition in file anyargs.h.
| #define RUBY_METHOD_FUNC | ( | func | ) |
This macro is to properly cast a function parameter of *_define_method family.
It has been around since 1.x era so you can maximise backwards compatibility by using it.
| func | A pointer to a function that implements a method. |