随着最近的 Xcode 5.1 更新,我们的代码库中出现了一系列新警告 -
这显然与 now warns 的更新版本的 clang 有关。关于在 C++11 源代码中 register
存储类说明符的用法为 it has been deprecated with C++11 :
/Users/me/Documents/Sources/boost/boost/log/attributes/attribute_set.hpp:288:9: 'register' storage class specifier is deprecated
现在我们想取消对我们无法更改的代码的警告 - 就像上面示例中的 BOOST 源代码。
我可以找到编译器标志来打开警告(-Wdeprecated-register
),但是是否有相反的方法可以从 Xcode 设置中禁用警告..?
最佳答案
一般来说,在选项前面加上 no-
会关闭它。所以如果 -Wdeprecated-register
启用警告,那么 -Wno-deprecated-register
应该禁用它。
或者,在许多编译器上,您可以在代码中使用编译指示(或类似的)来禁用警告,同时包含特定的 header ,同时为您自己的代码启用它们。它们是特定于编译器的;对于 Clang,它类似于
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#include "dodgy.hpp"
#pragma clang diagnostic pop
(对于 GCC,pragma 相同,只是将 clang
替换为 GCC
。我不知道任何其他编译器。)
关于c++ - 关闭 "' 寄存器的存储类说明符已弃用“警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22422741/