diff --git a/python/core/qgis.sip.in b/python/core/qgis.sip.in index 9a7dd9b003c..6e8996a06e6 100644 --- a/python/core/qgis.sip.in +++ b/python/core/qgis.sip.in @@ -213,6 +213,10 @@ typedef unsigned long long qgssize; + + + + /************************************************************************ * This file has been generated automatically from * * * diff --git a/src/core/qgis.h b/src/core/qgis.h index 71866aefd93..a5cd3a9c47e 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -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 + + +