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