Skip to content

Commit

Permalink
add C++17 [[maybe_unused]] and [[no_discard]]
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Feb 28, 2018
1 parent 95ab3d0 commit 8989292
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/core/qgis.sip.in
Expand Up @@ -213,6 +213,10 @@ typedef unsigned long long qgssize;







/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
25 changes: 25 additions & 0 deletions src/core/qgis.h
Expand Up @@ -548,4 +548,29 @@ typedef unsigned long long qgssize;
#define FALLTHROUGH
#endif

// see https://infektor.net/posts/2017-01-19-using-cpp17-attributes-today.html#using-the-nodiscard-attribute
#if __cplusplus >= 201703L
#define NODISCARD [[nodiscard]]
#elif defined(__clang__)
#define NODISCARD [[nodiscard]]
#elif __has_cpp_attribute(nodiscard)
#define NODISCARD [[nodiscard]]
#elif __has_cpp_attribute(gnu::warn_unused_result)
#define NODISCARD [[gnu::warn_unused_result]]
#else
#define NODISCARD Q_REQUIRED_RESULT
#endif

#if __cplusplus >= 201703L
#define MAYBE_UNUSED [[maybe_unused]]
#elif defined(__clang__)
#define MAYBE_UNUSED [[maybe_unused]]
#elif __has_cpp_attribute(gnu::unused)
#define NODISCARD [[gnu::unused]]
#else
#define NODISCARD
#endif




0 comments on commit 8989292

Please sign in to comment.