debug: use macros for DEBUG_ONLY macro

This commit is contained in:
Danny Robson 2018-03-20 14:49:46 +11:00
parent 8212048750
commit 0cf530c2de

View File

@ -36,8 +36,18 @@
///----------------------------------------------------------------------------
/// enable some code only if assertions et al are enabled
#define DEBUG_ONLY(X) do { if constexpr (debug_enabled) { X } } while (0)
/// enable some code only if assertions are enabled
///
/// explicitly does not use constexpr if to remove the code as some paths may
/// refer to variables which do not always exist, and current compiler
/// implementations are a little picky here.
#ifndef NDEBUG
#define DEBUG_ONLY(X) do { X; } while (0)
#else
#define DEBUG_ONLY(X) do { ; } while (0)
#endif
//#define DEBUG_ONLY(X) do { if constexpr (debug_enabled) { X } } while (0)
///////////////////////////////////////////////////////////////////////////////