开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜