Ways to specify [[nodiscard]] before C++17

2.9k views Asked by At

I need the semantics of the [[nodiscard]] attribute in a non-C++17 codebase. I guess there are compiler dependent ways of achieving this before C++17. Does anyone know these? I am interested in the ones for clang,gcc, and MSVC.

1

There are 1 answers

1
Nikolai Shalakin On BEST ANSWER
  • GCC/Clang: __attribute__((warn_unused_result))
  • MSVC: _Check_return_ for _MSC_VER >= 1700 (Visual Studio 2012)