debug: expose NDEBUG as a constexpr bool
This commit is contained in:
parent
c1aa0f7a3d
commit
d0e49fb1a8
13
debug.hpp
13
debug.hpp
@ -24,13 +24,22 @@
|
|||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// it is fractionally easier to define a constexpr variable which can be used
|
||||||
|
// in constexpr-if to enable/disable some codepaths rather than deal with
|
||||||
|
// macros in some scenarios. eg, templates are complicated enough without
|
||||||
|
// (more) macros.
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
#define DEBUG_ONLY(X) do { X } while (0)
|
constexpr bool debug_enabled = true;
|
||||||
#else
|
#else
|
||||||
#define DEBUG_ONLY(X) do { } while (0)
|
constexpr bool debug_enabled = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
///----------------------------------------------------------------------------
|
||||||
|
/// enable some code only if assertions et al are enabled
|
||||||
|
#define DEBUG_ONLY(X) do { if constexpr (debug_enabled) { X } } while (0)
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define EXIT_XSUCCESS 0
|
#define EXIT_XSUCCESS 0
|
||||||
#define EXIT_XSKIP 77
|
#define EXIT_XSKIP 77
|
||||||
|
Loading…
Reference in New Issue
Block a user