From e7110afe254c766ae7ad2c2f3639ef66040610f6 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sun, 20 May 2018 22:44:46 -0700 Subject: [PATCH] WARN_UNUSED_RESULT for windows --- .../implementations/integrity/KnownBlockVersions.h | 2 +- src/blockstore/interface/BlockStore2.h | 6 +++--- src/cpp-utils/macros.h | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/blockstore/implementations/integrity/KnownBlockVersions.h b/src/blockstore/implementations/integrity/KnownBlockVersions.h index c01d84c6..32c4034e 100644 --- a/src/blockstore/implementations/integrity/KnownBlockVersions.h +++ b/src/blockstore/implementations/integrity/KnownBlockVersions.h @@ -21,7 +21,7 @@ namespace blockstore { KnownBlockVersions(KnownBlockVersions &&rhs); // NOLINT (intentionally not noexcept) ~KnownBlockVersions(); - __attribute__((warn_unused_result)) + WARN_UNUSED_RESULT bool checkAndUpdateVersion(uint32_t clientId, const BlockId &blockId, uint64_t version); uint64_t incrementVersion(const BlockId &blockId); diff --git a/src/blockstore/interface/BlockStore2.h b/src/blockstore/interface/BlockStore2.h index 36032e68..affb69f8 100644 --- a/src/blockstore/interface/BlockStore2.h +++ b/src/blockstore/interface/BlockStore2.h @@ -19,12 +19,12 @@ public: return BlockId::Random(); } - __attribute__((warn_unused_result)) + WARN_UNUSED_RESULT virtual bool tryCreate(const BlockId &blockId, const cpputils::Data &data) = 0; - __attribute__((warn_unused_result)) + WARN_UNUSED_RESULT virtual bool remove(const BlockId &blockId) = 0; - __attribute__((warn_unused_result)) + WARN_UNUSED_RESULT virtual boost::optional load(const BlockId &blockId) const = 0; // Store the block with the given blockId. If it doesn't exist, it is created. diff --git a/src/cpp-utils/macros.h b/src/cpp-utils/macros.h index a07baca5..a34563db 100644 --- a/src/cpp-utils/macros.h +++ b/src/cpp-utils/macros.h @@ -17,4 +17,13 @@ */ #define UNUSED(expr) (void)(expr) +/** + * Warn if function result is unused + */ +#if !defined(_MSC_VER) +#define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define WARN_UNUSED_RESULT _Check_return_ +#endif + #endif