freerange / mocha

A mocking and stubbing library for Ruby
https://mocha.jamesmead.org
Other
1.23k stars 158 forks source link

Fix jaro_winkler compilation errors on MacOS #671

Closed floehopper closed 3 months ago

floehopper commented 3 months ago

Previously I was seeing compilation errors like the following when running bundle install on recent versions of Ruby:

jaro_winkler.c:19:3: error: incompatible function pointer types passing 'VALUE (size_t, VALUE *, VALUE)' (aka 'unsigned long (unsigned long, unsigned long *, unsigned long)') to parameter
of type 'VALUE (*)(int, union (unnamed union at ~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), VALUE)' (aka 'unsigned long (*)(int, union
(unnamed at ~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1), unsigned long)') [-Wincompatible-function-pointer-types]
  rb_define_singleton_method(rb_mJaroWinkler, "distance",
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/anyargs.h:308:143: note: expanded from macro 'rb_define_singleton_method'
#define rb_define_singleton_method(obj, mid, func, arity)   RBIMPL_ANYARGS_DISPATCH_rb_define_singleton_method((arity), (func))((obj), (mid), (func), (arity))
                                                                                                                                              ^~~~~~
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/anyargs.h:271:1: note: passing argument to parameter here
RBIMPL_ANYARGS_DECL(rb_define_singleton_method, VALUE, const char *)
^
~/.asdf/installs/ruby/3.2.3/include/ruby-3.2.0/ruby/internal/anyargs.h:254:72: note: expanded from macro 'RBIMPL_ANYARGS_DECL'
RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _m1(__VA_ARGS__, VALUE(*)(int, union { VALUE *x; const VALUE *y; } __attribute__((__transparent_union__)), VALUE), int); \
                                                                   ^

This seems to be the issue described in tonytonyjan/jaro_winkler#51 which was fixed in tonytonyjan/jaro_winkler#52 and which was released in jaro_winkler v1.5.5.

floehopper commented 3 weeks ago

Released in v2.5.0.