Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I suppress g++ deprecation warnings in OCaml compilation when linking with C++ libraries?

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?

like image 768
jrk Avatar asked May 14 '11 22:05

jrk


2 Answers

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.

like image 194
jrk Avatar answered Nov 01 '22 01:11

jrk


I think you can just do

#pragma GCC diagnostic ignored "-Wwrite-strings"

In the C++ to suppress this.

like image 21
Gaius Avatar answered Nov 01 '22 00:11

Gaius