maintainer-feedback requested: [Bug 271706] graphics/rubygem-cairo: fix build with clang 16

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 29 May 2023 13:35:50 UTC
Bugzilla Automation <bugzilla@FreeBSD.org> has asked freebsd-ruby (Nobody)
<ruby@FreeBSD.org> for maintainer-feedback:
Bug 271706: graphics/rubygem-cairo: fix build with clang 16
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271706



--- Description ---
Clang 16 has a new error about incompatible function types, which shows
up when building graphics/rubygem-cairo:

  rb_cairo_surface.c:2354:3: error: incompatible function pointer types passing
'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *,
unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned
long (*)(unsigned long, unsigned long)')
[-Wincompatible-function-pointer-types]
    rb_define_method (rb_cCairo_GLSurface, "initialize",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded
from macro 'rb_define_method'
  #define rb_define_method(klass, mid, func, arity)	     
RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid),
(func), (arity))
									       
							^~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing
argument to parameter here
  RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
  ^
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:255:72: note: expanded
from macro 'RBIMPL_ANYARGS_DECL'
  RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__,
VALUE(*)(VALUE, VALUE), int); \
									 ^
  rb_cairo_surface.c:2368:3: error: incompatible function pointer types passing
'VALUE (int, VALUE *, VALUE)' (aka 'unsigned long (int, unsigned long *,
unsigned long)') to parameter of type 'VALUE (*)(VALUE, VALUE)' (aka 'unsigned
long (*)(unsigned long, unsigned long)')
[-Wincompatible-function-pointer-types]
    rb_define_method (rb_cCairo_GLTextureSurface, "initialize",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:287:135: note: expanded
from macro 'rb_define_method'
  #define rb_define_method(klass, mid, func, arity)	     
RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid),
(func), (arity))
									       
							^~~~~~
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:276:1: note: passing
argument to parameter here
  RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
  ^
  /usr/local/include/ruby-3.1/ruby/internal/anyargs.h:255:72: note: expanded
from macro 'RBIMPL_ANYARGS_DECL'
  RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _01(__VA_ARGS__,
VALUE(*)(VALUE, VALUE), int); \
									 ^

This is because rb_define_method's last argument is the 'arity' of the
method, and in case of cr_gl_surface_initialize() and
cr_gl_texture_surface_initialize() it should be -1 to indicate a
variable number of arguments.