gjtorikian / mathematical

Convert mathematical equations to SVGs, PNGs, or MathML. A general wrapper to Lasem and mtex2MML.
https://gjtorikian.github.io/mathematical/
MIT License
166 stars 31 forks source link

fix compile error: warning as error #135

Closed netcan closed 1 week ago

cmuellner commented 1 week ago

@gjtorikian, is there anything specific that is blocking this PR from landing? The linter error in the CI is a false positive (it complains about code that has not been changed in this PR).

This issue blocks asciidoc installations (asciidoc-mathematical depends on this package).

The error message while building is:

mathematical.c: In function ‘process’:
mathematical.c:138:77: error: passing argument 2 of ‘cairo_svg_surface_create_for_stream’ makes pointer from integer without a cast [-Wint-conversion]
  138 |     surface = cairo_svg_surface_create_for_stream (cairoSvgSurfaceCallback, self, width_pt, height_pt);
      |                                                                             ^~~~
      |                                                                             |
      |                                                                             VALUE {aka long unsigned int}
In file included from ./mathematical.h:18:
/usr/include/cairo/cairo-svg.h:102:57: note: expected ‘void *’ but argument is of type ‘VALUE’ {aka ‘long unsigned int’}
  102 |                                      void              *closure,
      |                                      ~~~~~~~~~~~~~~~~~~~^~~~~~~
mathematical.c:149:91: error: passing argument 3 of ‘cairo_surface_write_to_png_stream’ makes pointer from integer without a cast [-Wint-conversion]
  149 |     cairo_surface_write_to_png_stream (cairo_get_target (cairo), cairoPngSurfaceCallback, self);
      |                                                                                           ^~~~
      |                                                                                           |
      |                                                                                           VALUE {aka long unsigned int}
In file included from /home/cm/.local/share/gem/ruby/gems/mathematical-1.6.18/ext/mathematical/lasem/src/lsmcairo.h:28,
                 from /home/cm/.local/share/gem/ruby/gems/mathematical-1.6.18/ext/mathematical/lasem/src/lsm.h:29,
                 from ./mathematical.h:11:
/usr/include/cairo/cairo.h:2606:58: note: expected ‘void *’ but argument is of type ‘VALUE’ {aka ‘long unsigned int’}
 2606 |                                    void                 *closure);
      |                                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
mathematical.c: In function ‘MATHEMATICAL_process’:
mathematical.c:232:40: error: passing argument 2 of ‘rb_rescue’ makes integer from pointer without a cast [-Wint-conversion]
  232 |     output = rb_rescue(process_helper, args, process_rescue, rb_Input);
      |                                        ^~~~
      |                                        |
      |                                        VALUE * {aka long unsigned int *}
In file included from /usr/include/ruby/ruby.h:41:
/usr/include/ruby/internal/iterator.h:364:47: note: expected ‘VALUE’ {aka ‘long unsigned int’} but argument is of type ‘VALUE *’ {aka ‘long unsigned int *’}
  364 | VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
      |                                         ~~~~~~^~~~~
mathematical.c:256:40: error: passing argument 2 of ‘rb_rescue’ makes integer from pointer without a cast [-Wint-conversion]
  256 |       hash = rb_rescue(process_helper, args, process_rescue, math);
      |                                        ^~~~
      |                                        |
      |                                        VALUE * {aka long unsigned int *}
/usr/include/ruby/internal/iterator.h:364:47: note: expected ‘VALUE’ {aka ‘long unsigned int’} but argument is of type ‘VALUE *’ {aka ‘long unsigned int *’}
  364 | VALUE rb_rescue(VALUE (*b_proc)(VALUE), VALUE data1, VALUE (*r_proc)(VALUE, VALUE), VALUE data2);
      |                                         ~~~~~~^~~~~
mathematical.c:265:12: error: assignment to ‘VALUE’ {aka ‘long unsigned int’} from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
  265 |     output = NULL;
      |            ^

Please let me know if anything can be done to merge this faster.

cmuellner commented 1 week ago

Workaround for people that land here and don't know what to do:

This was all needed to get the AsciiDoc stack installed and working on Fedora 40.

4e554c4c commented 1 week ago

The casts in #133 look more sound

cmuellner commented 1 week ago

The casts in #133 look more sound

I don't see why they are not equivalent. Further, #133 includes two unrelated changes (gitignore and fixes for the *test.rb files). But anyway, I'm fine with any of the PRs landing.

4e554c4c commented 1 week ago

closed in favor of #136. feel free to open another PR if this does not resolve the issue.

cmuellner commented 1 week ago

Works for me! Thanks!