我在我的 .cpp 文件中包含了几个第 3 方 header (当然包装在 extern "C"
中),并且我从字符串中得到了烦人的 deprecated conversion constant to 'char*'
在编译期间警告,即使我不调用头文件中定义的函数。鉴于我无法更改 header ,有没有什么好方法可以让这些警告静音/忽略,或者我只能忍受它们?
最佳答案
这取决于您的编译器。以下是您要为 g++ 做的事情:
#pragma GCC diagnostic ignored "-Wwrite-strings"
#include <files that generate the warning>
#pragma GCC diagnostic warning "-Wwrite-strings"
关于C++ - 在第 3 方 header 中弃用了从字符串常量到 ‘char*’ 的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9123011/