swig / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
5.81k stars 1.24k forks source link

error: invalid conversion from ‘const caml_value_t*’ {aka ‘const long int*’} to ‘caml_value_t*’ {aka ‘long int*’} #1686

Closed ellson closed 4 years ago

ellson commented 4 years ago

I got this error (and a few other similar errors) from swig generated code:


CXX libgv_ocaml_la-gv_ocaml.lo gv_ocaml.cpp: In function ‘long int caml_long_val_full(caml_value_t, const char)’: gv_ocaml.cpp:1362:48: error: invalid conversion from ‘const caml_value_t’ {aka ‘const long int’} to ‘caml_value_t’ {aka ‘long int*’} [-fpermissive] 1362 CAML_VALUE *enum_to_int = caml_named_value(SWIG_MODULE "_enum_to_int"); ~~~~^~~~~~~~
const caml_value_t {aka const long int}

when building graphviz (www.graphviz.org) on Fedora32 (aka rawhide) using gcc-9.2.1-1.fc32.3.x86_64 swig-4.0.1-3.fc32.x86_64

I was able to work-around the issue by adding -fpermissive to the CPPFLAGS for this file.

ellson commented 4 years ago

This issue does not occur on Fedora31 using: gcc-9.2.1-1.fc31.x86_64 swig-4.0.1-3.fc31.x86_64 ocaml-4.08.1-0.rc2.1.fc31.x86_64

The version of ocaml on fc32 is: ocaml-4.09.0-3.fc32.x86_64

So perhaps the error is not the result of a change in swig, but instead change in gcc or in the latest ocaml?

anatol commented 4 years ago

I see similar issue wit Arch Linux that uses ocaml 4.09.0

example_wrap.c: In member function ‘virtual bool SwigDirector_shape::cover(double, double)’:
example_wrap.c:2098:43: error: invalid conversion from ‘const caml_value_t*’ {aka ‘const long int*’} to ‘caml_value_t*’ {aka ‘long int*’} [-fpermissive]
 2098 |     swig_ocaml_func_val = caml_named_value("swig_runmethod");
      |                           ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
      |                                           |
      |                                           const caml_value_t* {aka const long int*}

I think newer version of ocaml modified API.

ZackerySpytz commented 4 years ago

caml_named_value() was modified to return a const value* in OCaml 4.09.0 (ocaml/ocaml@9f0bebf). I have opened #1693 to fix this issue.