[英]Ways to specify [[nodiscard]] before C++17
I need the semantics of the [[nodiscard]]
attribute in a non-C++17 codebase. 我需要非C ++ 17代码库中[[nodiscard]]
属性的语义。 I guess there are compiler dependent ways of achieving this before C++17. 我想在C ++ 17之前有编译器相关的方法来实现这一点。 Does anyone know these? 有谁知道这些? I am interested in the ones for clang,gcc, and MSVC. 我对clang,gcc和MSVC感兴趣。
__attribute__((warn_unused_result))
GCC / Clang: __attribute__((warn_unused_result))
_Check_return_
for _MSC_VER >= 1700
(Visual Studio 2012) MSVC: _Check_return_
for _MSC_VER >= 1700
(Visual Studio 2012)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.