Skip to content

Fix C23 (GCC 15) WIN32 compatibility for rb_define_* functions #13202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025

Conversation

XrXr
Copy link
Member

@XrXr XrXr commented Apr 29, 2025

No description provided.

Copy link

All Tests passed!

✖️no tests failed ✔️61958 tests passed(3 flakes)

@XrXr XrXr marked this pull request as ready for review April 29, 2025 13:03
@MSP-Greg
Copy link
Contributor

@XrXr

Thanks for this. I just ran it with GCC 15 and it passed. The only warnings were existing digest warnings.

See commit for a temporary way to install GCC 15. It adds about 25 seconds to the setup, but given the overall time for the job, it's not bad. The commit removes a 'spacing' blank line, not needed...

That time would drop if I make changes as mentioned in the Ruby issue tracker.

To lock to a commit for the action, use

uses: ruby/setup-ruby-pkgs@1493c009477b19efcb54cfaf72b5f9d1fd6ba86c # v1.33.2

Comment on lines +362 to +368
#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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, and use RBIMPL_CAST.

Suggested change
#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))
#define rb_define_method(klass, mid, func, arity) rb_define_method((klass), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_method_id(klass, mid, func, arity) rb_define_method_id((klass), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_singleton_method(obj, mid, func, arity) rb_define_singleton_method((obj), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_protected_method(klass, mid, func, arity) rb_define_protected_method((klass), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_private_method(klass, mid, func, arity) rb_define_private_method((klass), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_module_function(mod, mid, func, arity) rb_define_module_function((mod), (mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))
#define rb_define_global_function(mid, func, arity) rb_define_global_function((mid), RBIMPL_CAST((VALUE (*)(ANYARGS))(func)), (arity))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not necessary since it's !defined(__cplusplus).

@XrXr XrXr merged commit 719486a into ruby:master Apr 30, 2025
83 of 86 checks passed
@XrXr XrXr deleted the mingw-gcc15 branch April 30, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants