Skip to content

Commit ea19efe

Browse files
committed
use a macro for assertions to get proper error output including location
1 parent 6bdf8c9 commit ea19efe

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

include/reactor-cpp/assert.hh

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,14 @@ constexpr inline void validate([[maybe_unused]] bool condition, [[maybe_unused]]
6767
}
6868
}
6969

70-
// Use plain assert on Windows and when assertions are enabled.
71-
// Otherwise, the locations of assertion errors are not properly reported.
72-
#if defined(_WIN32) && !defined(NDEBUG)
73-
#define reactor_assert(condition) assert(condition)
70+
// assert macro that avoids unused variable warnings
71+
#ifdef NDEBUG
72+
#define reactor_assert(x) \
73+
do { \
74+
(void)sizeof(x); \
75+
} while (0)
7476
#else
75-
constexpr inline void reactor_assert([[maybe_unused]] bool condition) {
76-
if constexpr (runtime_assertion) { // NOLINT
77-
assert(condition); // NOLINT
78-
}
79-
}
77+
#define reactor_assert(x) assert(x)
8078
#endif
8179

8280
template <typename E> constexpr auto extract_value(E enum_value) -> typename std::underlying_type<E>::type {

0 commit comments

Comments
 (0)