Skip to content

Conversation

@skrobul
Copy link
Contributor

@skrobul skrobul commented Dec 18, 2025

Hello @bjmllr ! :-)
This PR fixes function signature for initialize method so that the gem compiles with newer versions of ruby.
The second commit is mostly to silence the -Wparentheses warnings.

If you could release new version post-merge, I'd greatly appreciate your help.

thanks,
Marek

Fix initialize function signature for Ruby 3.x compatibility where the
arity checks are enforced. This is done by removing unused input_text
parameter to match arity 0 declaration.

Fixes:

```
In file included from /usr/local/include/ruby-3.1.0/ruby/ruby.h:26,
                 from /usr/local/include/ruby-3.1.0/ruby.h:38,
                 from ../../../../ext/ios_parser/c_lexer/lexer.c:1:
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'Init_c_lexer':
/usr/local/include/ruby-3.1.0/ruby/internal/anyargs.h:287:135: error: passing argument 3 of 'rb_define_method_00' from incompatible pointer type [-Wincompatible-pointer-types]
  287 | , mid, func, arity)           RBIMPL_ANYARGS_DISPATCH_rb_define_method((arity), (func))((klass), (mid), (func), (arity))
      |                                                                                                         ^~~~~~
      |                                                                                                         |
      |                                                                                                         VALUE (*)(VALUE,  VALUE) {aka long unsigned int (*)(long unsigned int,  long unsigned int)}

../../../../ext/ios_parser/c_lexer/lexer.c:610:5: note: in expansion of macro 'rb_define_method'
  610 |     rb_define_method(rb_cCLexer, "initialize", initialize, 0);
 /usr/local/include/ruby-3.1.0/ruby/internal/anyargs.h:276:21: note: expected 'VALUE (*)(VALUE)' {aka 'long unsigned int (*)(long unsigned int)'} but argument is of type 'VALUE (*)(VALUE,  VALUE)' {aka 'long unsigned int (*)(long unsigned int,  long unsigned int)'}
  276 | RBIMPL_ANYARGS_DECL(rb_define_method, VALUE, const char *)
      |                     ^~~~~~~~~~~~~~~~
/usr/local/include/ruby-3.1.0/ruby/internal/anyargs.h:254:41: note: in definition of macro 'RBIMPL_ANYARGS_DECL'
  254 | RBIMPL_ANYARGS_ATTRSET(sym) static void sym ## _00(__VA_ARGS__, VALUE(*)(VALUE), int); \
      |                                         ^~~
At top level:     |     ^~~~~~~~~~~~~~~~
```
Fixes:

```
compiling ../../../../ext/ios_parser/c_lexer/lexer.c
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'process_word':
../../../../ext/ios_parser/c_lexer/lexer.c:41:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   41 | #define IS_DIGIT(C)     '0' <= C && C <= '9'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:43:25: note: in expansion of macro 'IS_DIGIT'
   43 | #define IS_DECIMAL(C)   IS_DIGIT(C) || IS_DOT(C)
      |                         ^~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:25: note: in expansion of macro 'IS_DECIMAL'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                         ^~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:306:9: note: in expansion of macro 'IS_WORD'
  306 |     if (IS_WORD(c)) {
      |         ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:306:9: note: in expansion of macro 'IS_WORD'
  306 |     if (IS_WORD(c)) {
      |         ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                                                 ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:306:9: note: in expansion of macro 'IS_WORD'
  306 |     if (IS_WORD(c)) {
      |         ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'process_decimal':
../../../../ext/ios_parser/c_lexer/lexer.c:41:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   41 | #define IS_DIGIT(C)     '0' <= C && C <= '9'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:43:25: note: in expansion of macro 'IS_DIGIT'
   43 | #define IS_DECIMAL(C)   IS_DIGIT(C) || IS_DOT(C)
      |                         ^~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:25: note: in expansion of macro 'IS_DECIMAL'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                         ^~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:320:16: note: in expansion of macro 'IS_WORD'
  320 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:320:16: note: in expansion of macro 'IS_WORD'
  320 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                                                 ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:320:16: note: in expansion of macro 'IS_WORD'
  320 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'process_integer':
../../../../ext/ios_parser/c_lexer/lexer.c:41:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   41 | #define IS_DIGIT(C)     '0' <= C && C <= '9'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:43:25: note: in expansion of macro 'IS_DIGIT'
   43 | #define IS_DECIMAL(C)   IS_DIGIT(C) || IS_DOT(C)
      |                         ^~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:25: note: in expansion of macro 'IS_DECIMAL'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                         ^~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:342:16: note: in expansion of macro 'IS_WORD'
  342 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:342:16: note: in expansion of macro 'IS_WORD'
  342 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                                                 ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:342:16: note: in expansion of macro 'IS_WORD'
  342 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'is_banner_end_char':
../../../../ext/ios_parser/c_lexer/lexer.c:408:23: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  408 |         (0 < lex->pos && '\n' == lex->text[lex->pos - 1] ||
      |          ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c: In function 'process_root':
../../../../ext/ios_parser/c_lexer/lexer.c:41:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   41 | #define IS_DIGIT(C)     '0' <= C && C <= '9'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:43:25: note: in expansion of macro 'IS_DIGIT'
   43 | #define IS_DECIMAL(C)   IS_DIGIT(C) || IS_DOT(C)
      |                         ^~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:25: note: in expansion of macro 'IS_DECIMAL'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                         ^~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:519:16: note: in expansion of macro 'IS_WORD'
  519 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:34: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                         ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:519:16: note: in expansion of macro 'IS_WORD'
  519 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:44:58: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   44 | #define IS_LETTER(C)    'a' <= C && C <= 'z' || 'A' <= C && C <= 'Z'
      |                                                 ~~~~~~~~~^~~~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:46:42: note: in expansion of macro 'IS_LETTER'
   46 | #define IS_WORD(C)      IS_DECIMAL(C) || IS_LETTER(C) || IS_PUNCT(C)
      |                                          ^~~~~~~~~
../../../../ext/ios_parser/c_lexer/lexer.c:519:16: note: in expansion of macro 'IS_WORD'
  519 |     } else if (IS_WORD(c)) {
      |                ^~~~~~~
```
@skrobul skrobul force-pushed the compile-with-ruby31 branch 3 times, most recently from 1bd079a to d656931 Compare December 18, 2025 11:15
@skrobul skrobul force-pushed the compile-with-ruby31 branch from d656931 to 735a97f Compare December 18, 2025 11:18
@stevekeay
Copy link

Hi again BM, happy to take on maintainership duties if it helps.

Copy link
Owner

@bjmllr bjmllr left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bjmllr bjmllr merged commit 5bbcdd4 into bjmllr:master Jan 3, 2026
12 checks passed
@bjmllr
Copy link
Owner

bjmllr commented Jan 3, 2026

Hey folks, hope you had some happy holidays!

Released as 0.9.1 at https://rubygems.org/gems/ios_parser/versions/0.9.1

Send me an email if you want push access on rubygems.org - my username at my username dot com

@skrobul skrobul deleted the compile-with-ruby31 branch January 6, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants