socketry / nio4r

Cross-platform asynchronous I/O primitives for scalable network clients and servers.
Other
970 stars 86 forks source link

Compilation failure under Linux 41, gcc 14.2.1 #323

Closed dov closed 2 weeks ago

dov commented 2 weeks ago

gem pristine nio4r --version 2.5.8 fails under Fedora 41 with the following error:

selector.c: In function ‘NIO_Selector_synchronize’:
selector.c:301:26: error: passing argument 1 of ‘rb_ensure’ from incompatible pointer type [-Wincompatible-pointer-types]
  301 |         return rb_ensure(func, (VALUE)args, NIO_Selector_unlock, self);
      |                          ^~~~
      |                          |
      |                          VALUE (*)(VALUE *) {aka long unsigned int (*)(long unsigned int *)}
In file included from /usr/include/ruby/ruby.h:41,
                 from /usr/include/ruby.h:38,
                 from nio4r.h:10:
/usr/include/ruby/internal/iterator.h:425:25: note: expected ‘VALUE (*)(VALUE)’ {aka ‘long unsigned int (*)(long unsigned int)’} but argument is of type ‘VALUE (*)(VALUE *)’ {aka ‘long unsigned int (*)(long unsigned int *)’}
  425 | VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
      |                 ~~~~~~~~^~~~~~~~~~~~~~

This can be worked around by the following trivial patch:

301c301
<         return rb_ensure(func, (VALUE)args, NIO_Selector_unlock, self);
---
>         return rb_ensure((void*)func, (VALUE)args, NIO_Selector_unlock, self);
ioquatix commented 2 weeks ago

Thanks for your report, this should be an easy fix.

ioquatix commented 2 weeks ago

I reviewed the issue. It turns out this was already fixed in https://github.com/socketry/nio4r/commit/dd69a1c053bf13a580ec6a4e392c15c269239fd6

Please update to the latest version of nio4r.