unicode icon indicating copy to clipboard operation
unicode copied to clipboard

Incompatible function pointer types

Open emezac opened this issue 11 months ago • 9 comments

Arquitecture: MacOS Sonoma 14.4 Ruby: ruby 3.2.0 (2022-12-25 revision a528908271) [arm64-darwin23]

Incompatible function pointer types: The errors occurred when passing function pointers as arguments to the rb_ensure function. The rb_ensure function expects the first argument to be a function pointer that takes a single VALUE parameter and returns a VALUE.

However, the function pointers being passed (get_text_elements_internal, get_categories_internal) had different parameter types (get_text_elements_param*, get_categories_param*) instead of VALUE. To fix this, you need to modify the function definitions to take a VALUE parameter and convert it to the appropriate pointer type inside the function.

Operand type mismatch: The errors occurred when attempting to convert a variable of type WString directly to VALUE. The WString type is a struct, not a pointer or arithmetic type, so it cannot be directly converted to VALUE. To fix this, you need to pass the address of the WString variable as a pointer and then convert that pointer to VALUE using a cast.

Incompatible function pointer types in the ensure callback: The errors occurred when passing function pointers as the ensure callback to the rb_ensure function. The rb_ensure function expects the ensure callback to be a function pointer that takes a single VALUE parameter and returns a VALUE.

However, the ensure callback functions (get_text_elements_ensure, get_categories_ensure) had a different parameter type (WString*) instead of VALUE.

To fix this, you need to modify the ensure callback functions to take a VALUE parameter and convert it back to a WString* pointer inside the function.

Overall, the main issues were related to incompatible function pointer types and incorrect type conversions when passing arguments to the rb_ensure function. The fixes involve modifying the function definitions and ensure callbacks to take VALUE parameters and perform the necessary type conversions inside the functions.

emezac avatar Mar 11 '24 17:03 emezac

Awesome, thank you we are dealing with the same issue. Seem to work fine now.

gastonmorixe avatar Mar 11 '24 23:03 gastonmorixe

FYI @blackwinter.

I think I'm also seeing this on macOS 14.4 with an M2 Pro chip and Ruby 3.2.2.

$ gem install unicode -v 0.4.4.4
Building native extensions. This could take a while...
ERROR:  Error installing unicode:
	ERROR: Failed to build gem native extension.

    current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
.../bin/ruby extconf.rb
creating Makefile

current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240312-3995-vnjxxu sitelibdir\=./.gem.20240312-3995-vnjxxu clean

current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240312-3995-vnjxxu sitelibdir\=./.gem.20240312-3995-vnjxxu
compiling unicode.c
unicode.c:37:7: warning: 'RB_OBJ_TAINTED' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
  if (OBJ_TAINTED(src))
      ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:151:25: note: expanded from macro 'OBJ_TAINTED'
#define OBJ_TAINTED     RB_OBJ_TAINTED     /**< @old{RB_OBJ_TAINTED} */
                        ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:118:30: note: expanded from macro 'RB_OBJ_TAINTED'
#define RB_OBJ_TAINTED       RB_OBJ_TAINTED
                             ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:812:1: note: 'RB_OBJ_TAINTED' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
.../include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:38:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
    OBJ_TAINT(obj);
    ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:149:25: note: expanded from macro 'OBJ_TAINT'
#define OBJ_TAINT       RB_OBJ_TAINT       /**< @old{RB_OBJ_TAINT} */
                        ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:116:30: note: expanded from macro 'RB_OBJ_TAINT'
#define RB_OBJ_TAINT         RB_OBJ_TAINT
                             ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:843:1: note: 'RB_OBJ_TAINT' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
.../include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:646:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr1, RSTRING_PTR(str1), RSTRING_LEN(str1));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:647:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr2, RSTRING_PTR(str2), RSTRING_LEN(str2));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:688:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr1, RSTRING_PTR(str1), RSTRING_LEN(str1));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:689:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr2, RSTRING_PTR(str2), RSTRING_LEN(str2));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:725:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:751:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:777:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:803:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:830:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:860:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:890:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:919:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:945:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:976:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1039:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1040:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1037:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1057:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1058:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1055:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1079:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1227:20: error: incompatible function pointer types passing 'VALUE (get_text_elements_param *)' (aka 'unsigned long (struct _get_text_elements_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_text_elements_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1228:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_text_elements_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1225:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
20 warnings and 6 errors generated.
make: *** [unicode.o] Error 1

make failed, exit code 2

Gem files will remain installed in .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4 for inspection.
Results logged to .../lib/ruby/gems/3.2.0/extensions/arm64-darwin-23/3.2.0/unicode-0.4.4.4/gem_make.out
~/SpringCare/xerneas/apps/rotom (master <)$ gem install pragmatic_segmenter
Fetching pragmatic_segmenter-0.3.23.gem
Building native extensions. This could take a while...
ERROR:  Error installing pragmatic_segmenter:
	ERROR: Failed to build gem native extension.

    current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
.../bin/ruby extconf.rb
creating Makefile

current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240312-12457-cd097q sitelibdir\=./.gem.20240312-12457-cd097q clean

current directory: .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4/ext/unicode
make DESTDIR\= sitearchdir\=./.gem.20240312-12457-cd097q sitelibdir\=./.gem.20240312-12457-cd097q
compiling unicode.c
unicode.c:37:7: warning: 'RB_OBJ_TAINTED' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
  if (OBJ_TAINTED(src))
      ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:151:25: note: expanded from macro 'OBJ_TAINTED'
#define OBJ_TAINTED     RB_OBJ_TAINTED     /**< @old{RB_OBJ_TAINTED} */
                        ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:118:30: note: expanded from macro 'RB_OBJ_TAINTED'
#define RB_OBJ_TAINTED       RB_OBJ_TAINTED
                             ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:812:1: note: 'RB_OBJ_TAINTED' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
.../include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:38:5: warning: 'RB_OBJ_TAINT' is deprecated: taintedness turned out to be a wrong idea. [-Wdeprecated-declarations]
    OBJ_TAINT(obj);
    ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:149:25: note: expanded from macro 'OBJ_TAINT'
#define OBJ_TAINT       RB_OBJ_TAINT       /**< @old{RB_OBJ_TAINT} */
                        ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:116:30: note: expanded from macro 'RB_OBJ_TAINT'
#define RB_OBJ_TAINT         RB_OBJ_TAINT
                             ^
.../include/ruby-3.2.0/ruby/internal/fl_type.h:843:1: note: 'RB_OBJ_TAINT' has been explicitly marked deprecated here
RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
^
.../include/ruby-3.2.0/ruby/internal/attr/deprecated.h:36:53: note: expanded from macro 'RBIMPL_ATTR_DEPRECATED'
# define RBIMPL_ATTR_DEPRECATED(msg) __attribute__((__deprecated__ msg))
                                                    ^
unicode.c:646:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr1, RSTRING_PTR(str1), RSTRING_LEN(str1));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:647:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr2, RSTRING_PTR(str2), RSTRING_LEN(str2));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:688:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr1, RSTRING_PTR(str1), RSTRING_LEN(str1));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:689:50: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr2, RSTRING_PTR(str2), RSTRING_LEN(str2));
  ~~~~~~~~~~~~~~~~~~~                            ^~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:725:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:751:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:777:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:803:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:830:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:860:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:890:49: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr1, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                           ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:919:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:945:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:976:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&ustr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1039:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1040:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1037:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1057:20: error: incompatible function pointer types passing 'VALUE (get_categories_param *)' (aka 'unsigned long (struct _get_categories_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_categories_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1058:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_categories_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1055:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1079:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
unicode.c:1227:20: error: incompatible function pointer types passing 'VALUE (get_text_elements_param *)' (aka 'unsigned long (struct _get_text_elements_param *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
  return rb_ensure(get_text_elements_internal, (VALUE)&param,
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:25: note: passing argument to parameter 'b_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                        ^
unicode.c:1228:20: error: incompatible function pointer types passing 'VALUE (WString *)' (aka 'unsigned long (struct _WString *)') to parameter of type 'VALUE (*)(VALUE)' (aka 'unsigned long (*)(unsigned long)') [-Wincompatible-function-pointer-types]
                   get_text_elements_ensure, (VALUE)&wstr);
                   ^~~~~~~~~~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/iterator.h:425:62: note: passing argument to parameter 'e_proc' here
VALUE rb_ensure(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*e_proc)(VALUE), VALUE data2);
                                                             ^
unicode.c:1225:48: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
  WStr_allocWithUTF8L(&wstr, RSTRING_PTR(str), RSTRING_LEN(str));
  ~~~~~~~~~~~~~~~~~~~                          ^~~~~~~~~~~~~~~~
.../include/ruby-3.2.0/ruby/internal/core/rstring.h:52:27: note: expanded from macro 'RSTRING_LEN'
#define RSTRING_LEN       RSTRING_LEN
                          ^
20 warnings and 6 errors generated.
make: *** [unicode.o] Error 1

make failed, exit code 2

Gem files will remain installed in .../lib/ruby/gems/3.2.0/gems/unicode-0.4.4.4 for inspection.
Results logged to .../lib/ruby/gems/3.2.0/extensions/arm64-darwin-23/3.2.0/unicode-0.4.4.4/gem_make.out

dijonkitchen avatar Mar 12 '24 14:03 dijonkitchen

I'm also seeing the issue that @dijonkitchen reported on macOS 14.3 with an M3 chip and Ruby 3.3.0.

anthonysapien avatar Mar 15 '24 21:03 anthonysapien

@gastonmorixe did you edit the files locally to unblock the issue? Thanks!

anthonysapien avatar Mar 15 '24 21:03 anthonysapien

Thank you for taking the time to provide these fixes, but I'm not sure how to proceed here. This repository has always served as a mirror only (see the contributing guidelines). Now I notice that the original author seems to have disappeared from the internet. However, I don't see myself taking up maintaining the library; I just don't have the need for it anymore.

So, I'm sorry to say, someone else has to step up if you want to continue using this library (at least on macOS).

blackwinter avatar Mar 18 '24 16:03 blackwinter

Ok I can take this repo as a temporary maintainer, I can provide patches from time to time, here in this repo : https://github.com/emezac/unicode

emezac avatar Mar 18 '24 20:03 emezac

Great, thanks @emezac!

blackwinter avatar Mar 18 '24 21:03 blackwinter

Just got same error as dijonkitchen. MacOS 14.4 Sonoma, M1 Pro ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [arm64-darwin23]

ilukashin avatar Mar 20 '24 15:03 ilukashin

The solution suggested in this thread worked for me: https://stackoverflow.com/questions/78129921/gemextbuilderror-error-failed-to-build-gem-native-extension-unicode-c1058

M2 Pro, Sonoma 14.4, ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23].

alpinweis avatar Mar 23 '24 22:03 alpinweis

I have this same problem with Fedora 40 and g++ 14, the @emezac branch compiled fine

AMD64

renatovico avatar Apr 25 '24 19:04 renatovico

As per stackoverflow, the following command worked for me without the PR:

gem install unicode -- --with-cflags="-Wno-incompatible-function-pointer-types"

drnic avatar May 02 '24 20:05 drnic

As per stackoverflow, the following command worked for me without the PR:

gem install unicode -- --with-cflags="-Wno-incompatible-function-pointer-types"

Worked for me, macos with M1

danmaz74 avatar May 05 '24 13:05 danmaz74

Great, thanks @emezac!

@blackwinter any update on if @emezac is a new maintainer that can merge this pull request and publish an updated gem?

dijonkitchen avatar May 09 '24 15:05 dijonkitchen

@blackwinter any update on if @emezac is a new maintainer that can merge this pull request and publish an updated gem?

No, I haven't heard anything. I would suggest you go with his fork or try the workaround mentioned by @drnic.

blackwinter avatar May 10 '24 09:05 blackwinter

Should be fixed in 0.4.4.5.

blackwinter avatar Jun 20 '24 11:06 blackwinter