merge revision(s) 719486a642f0e282b02b958069b8b39b85b3aa1e: [Backport #21286]
Fix C23 (GCC 15) WIN32 compatibility for rb_define_* functions Fixes [Bug #21286]
This commit is contained in:
parent
b133b39705
commit
f91480d7a6
@ -84,12 +84,15 @@
|
|||||||
|
|
||||||
#elif defined(_WIN32) || defined(__CYGWIN__)
|
#elif defined(_WIN32) || defined(__CYGWIN__)
|
||||||
# /* Skip due to [Bug #16134] */
|
# /* Skip due to [Bug #16134] */
|
||||||
|
# define RBIMPL_CAST_FN_PTR 1
|
||||||
|
|
||||||
#elif ! RBIMPL_HAS_ATTRIBUTE(transparent_union)
|
#elif ! RBIMPL_HAS_ATTRIBUTE(transparent_union)
|
||||||
# /* :TODO: improve here, please find a way to support. */
|
# /* :TODO: improve here, please find a way to support. */
|
||||||
|
# define RBIMPL_CAST_FN_PTR 1
|
||||||
|
|
||||||
#elif ! defined(HAVE_VA_ARGS_MACRO)
|
#elif ! defined(HAVE_VA_ARGS_MACRO)
|
||||||
# /* :TODO: improve here, please find a way to support. */
|
# /* :TODO: improve here, please find a way to support. */
|
||||||
|
# define RBIMPL_CAST_FN_PTR 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
# /** @cond INTERNAL_MACRO */
|
# /** @cond INTERNAL_MACRO */
|
||||||
@ -348,6 +351,25 @@ RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
|
|||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
#if defined(RBIMPL_CAST_FN_PTR) && !defined(__cplusplus)
|
||||||
|
/* In C23, K&R style prototypes are gone and so `void foo(ANYARGS)` became
|
||||||
|
* equivalent to `void foo(void)` unlike in earlier versions. This is a problem
|
||||||
|
* for rb_define_* functions since that makes all valid functions one can pass
|
||||||
|
* trip -Wincompatible-pointer-types, which we treat as errors. This is mostly
|
||||||
|
* not a problem for the __builtin_choose_expr path, but outside of that we
|
||||||
|
* need to add a cast for compatibility.
|
||||||
|
*/
|
||||||
|
#define rb_define_method(klass, mid, func, arity) rb_define_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_method_id(klass, mid, func, arity) rb_define_method_id((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_singleton_method(obj, mid, func, arity) rb_define_singleton_method((obj), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_protected_method(klass, mid, func, arity) rb_define_protected_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_private_method(klass, mid, func, arity) rb_define_private_method((klass), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_module_function(mod, mid, func, arity) rb_define_module_function((mod), (mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
#define rb_define_global_function(mid, func, arity) rb_define_global_function((mid), (VALUE (*)(ANYARGS))(func), (arity))
|
||||||
|
|
||||||
|
#undef RBIMPL_CAST_FN_PTR
|
||||||
|
#endif /* defined(RBIMPL_CAST_FN_PTR) && !defined(__cplusplus) */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This macro is to properly cast a function parameter of *_define_method
|
* 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
|
* family. It has been around since 1.x era so you can maximise backwards
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 8
|
#define RUBY_VERSION_TEENY 8
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 263
|
#define RUBY_PATCHLEVEL 264
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
#include "ruby/internal/abi.h"
|
#include "ruby/internal/abi.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user