关闭"'register' storage class specifier is deprecated"警告
Turning off the "'register' storage class specifier is deprecated" warning
随着最近Xcode 5.1的更新,我们在代码库中得到了一堆新的警告-
这显然与clang的更新版本有关,clang现在警告在c++ 11源代码中使用register
存储类说明符,因为它已在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
应该禁用它。
或者,在许多编译器上,您可以在代码中使用pragmas(或类似的)来禁用警告,同时包含特定的头文件,而将它们保留为您自己的代码启用。它们是特定于编译器的;对于Clang,它类似于
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-register"
#include "dodgy.hpp"
#pragma clang diagnostic pop
(对于GCC, pragmas是相同的,只是将clang
替换为GCC
。我不知道还有其他的编译器
在这里,抑制警告是错误的工具。当包含不是您的代码时,使用-isystem
标志,它将不会在该代码中生成警告。
#if __cplusplus > 199711L
#define register // Deprecated in C++11.
#endif // #if __cplusplus > 199711L
相关文章:
- Why is UINT32_MAX + 1 = 0?
- C++错误:"error: int aaa::bbb is protected within this context"
- 创建具有 new in 函数和"this is nullptr"异常的对象
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- Is !NaN not a NaN?
- Directx 11 - CompileFromFile() is not compiling
- Centos7 g++ "to_string is not in a member of std"
- "Unable to start debugging. No process is associated with this object." - 在Visual Studio Code中使用GDB
- Where is std::hardware_destructive_interference_size?
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- What is unordered_set in C++
- 你如何理解"std: :forward is just syntactic sugar"?这是真的吗?
- C++ "error: use of overloaded operator '*' is ambiguous"似乎只有一场比赛
- C++ is calculating wrong
- Is it good to use SDL_PIXELFORMAT_UNKNOWN?
- reference_wrapper导致"incomplete type is not allowed"
- 为什么即使在定义之后仍存在"Identifier is undefined error "?
- 结构中的错误"Incomplete type is not allowed"
- 编译器行为和"register storage class specifier is deprecated"
- 关闭"'register' storage class specifier is deprecated"警告