diff --git a/src/util.h b/src/util.h index 1f60601f85f311..48d9555c04fd4f 100644 --- a/src/util.h +++ b/src/util.h @@ -42,6 +42,12 @@ #include #include +#ifdef __GNUC__ +#define MUST_USE_RESULT __attribute__((warn_unused_result)) +#else +#define MUST_USE_RESULT +#endif + namespace node { // Maybe remove kPathSeparator when cpp17 is ready @@ -505,7 +511,7 @@ struct OnScopeLeaveImpl { // // ... run some code ... // }); template -inline OnScopeLeaveImpl OnScopeLeave(Fn&& fn) { +inline MUST_USE_RESULT OnScopeLeaveImpl OnScopeLeave(Fn&& fn) { return OnScopeLeaveImpl{std::move(fn)}; } @@ -686,12 +692,6 @@ constexpr T RoundUp(T a, T b) { return a % b != 0 ? a + b - (a % b) : a; } -#ifdef __GNUC__ -#define MUST_USE_RESULT __attribute__((warn_unused_result)) -#else -#define MUST_USE_RESULT -#endif - class SlicedArguments : public MaybeStackBuffer> { public: inline explicit SlicedArguments(