When compiling an OCaml project which links against libraries requiring the C++ standard library (e.g. LLVM's OCaml bindings) using the -cc g++
argument to ocamlc
with GCC >= 4.4 generates extremely verbose warning spew of the form:
warning: deprecated conversion from string constant to ‘char*’
How is it possible to remove these warnings?
The problem stems from ocamlc
generating intermediate C code which triggers warnings when compiled in C++ mode by newer versions of GCC. But this generated code need not be compiled as C++. The only reason to pass -cc g++
for this common case of building against a wrapped C++ library is to ensure that the C++ standard library dependencies are built. The simpler solution, which avoids using the C++ front-end for compiling the ocamlc
intermediate code, is simply:
-cclib -lstdc++
which forces linking the generated C code with libstdc++
, while still compiling it in plain C mode.
I think you can just do
#pragma GCC diagnostic ignored "-Wwrite-strings"
In the C++ to suppress this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With