Skip to content

Commit 1ec6e5b

Browse files
committed
move macro definition out of namespace
1 parent 5c1dcee commit 1ec6e5b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

include/reactor-cpp/assert.hh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ constexpr bool runtime_assertion = true;
3333
#include <unistd.h>
3434
#endif
3535

36+
// assert macro that avoids unused variable warnings
37+
#ifdef NDEBUG
38+
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
39+
#define reactor_assert(x) \
40+
do { \
41+
(void)sizeof(x); \
42+
} while (0)
43+
#else
44+
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
45+
#define reactor_assert(x) assert(x)
46+
#endif
47+
3648
namespace reactor {
3749
using EnvPhase = Environment::Phase;
3850

@@ -67,18 +79,6 @@ constexpr inline void validate([[maybe_unused]] bool condition, [[maybe_unused]]
6779
}
6880
}
6981

70-
// assert macro that avoids unused variable warnings
71-
#ifdef NDEBUG
72-
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
73-
#define reactor_assert(x) \
74-
do { \
75-
(void)sizeof(x); \
76-
} while (0)
77-
#else
78-
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
79-
#define reactor_assert(x) assert(x)
80-
#endif
81-
8282
template <typename E> constexpr auto extract_value(E enum_value) -> typename std::underlying_type<E>::type {
8383
return static_cast<typename std::underlying_type<E>::type>(enum_value);
8484
}

0 commit comments

Comments
 (0)