[英]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 (eg LLVM's OCaml bindings) using the -cc g++
argument to ocamlc
with GCC >= 4.4 generates extremely verbose warning spew of the form: 在编译OCaml项目时,该项目链接需要C ++标准库的库(例如LLVM的OCaml绑定),使用
ocamlc
-cc g++
参数到ocamlc
,GCC> = 4.4会生成以下形式的极其详细的警告:
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. 问题源于
ocamlc
生成中间C代码,当使用较新版本的GCC在C ++模式下编译时会触发警告。 But this generated code need not be compiled as C++. 但是这个生成的代码不需要编译为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. 为这种针对包装C ++库构建的常见情况传递
-cc g++
的唯一原因是确保构建C ++标准库依赖项。 The simpler solution, which avoids using the C++ front-end for compiling the ocamlc
intermediate code, is simply: 避免使用C ++前端编译
ocamlc
中间代码的简单解决方案很简单:
-cclib -lstdc++
which forces linking the generated C code with libstdc++
, while still compiling it in plain C mode. 它强制将生成的C代码与
libstdc++
链接起来,同时仍以纯C模式编译它。
I think you can just do 我想你可以做到
#pragma GCC diagnostic ignored "-Wwrite-strings"
In the C++ to suppress this. 在C ++中压制这个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.