Skip to content

Commit 8989292

Browse files
committed
add C++17 [[maybe_unused]] and [[no_discard]]
1 parent 95ab3d0 commit 8989292

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

python/core/qgis.sip.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ typedef unsigned long long qgssize;
213213

214214

215215

216+
217+
218+
219+
216220
/************************************************************************
217221
* This file has been generated automatically from *
218222
* *

src/core/qgis.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,29 @@ typedef unsigned long long qgssize;
548548
#define FALLTHROUGH
549549
#endif
550550

551+
// see https://infektor.net/posts/2017-01-19-using-cpp17-attributes-today.html#using-the-nodiscard-attribute
552+
#if __cplusplus >= 201703L
553+
#define NODISCARD [[nodiscard]]
554+
#elif defined(__clang__)
555+
#define NODISCARD [[nodiscard]]
556+
#elif __has_cpp_attribute(nodiscard)
557+
#define NODISCARD [[nodiscard]]
558+
#elif __has_cpp_attribute(gnu::warn_unused_result)
559+
#define NODISCARD [[gnu::warn_unused_result]]
560+
#else
561+
#define NODISCARD Q_REQUIRED_RESULT
562+
#endif
563+
564+
#if __cplusplus >= 201703L
565+
#define MAYBE_UNUSED [[maybe_unused]]
566+
#elif defined(__clang__)
567+
#define MAYBE_UNUSED [[maybe_unused]]
568+
#elif __has_cpp_attribute(gnu::unused)
569+
#define NODISCARD [[gnu::unused]]
570+
#else
571+
#define NODISCARD
572+
#endif
573+
574+
575+
551576

0 commit comments

Comments
 (0)