From ebe0a04325e871e466dd474a14d23b0085b80da9 Mon Sep 17 00:00:00 2001 From: Henrik Stickann <4376396-Mithradir@users.noreply.gitlab.com> Date: Sun, 1 May 2022 18:16:00 +0200 Subject: [PATCH] Rework module enable logic --- include/sta/debug_serial.hpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/include/sta/debug_serial.hpp b/include/sta/debug_serial.hpp index 8bf151e..90e4053 100644 --- a/include/sta/debug_serial.hpp +++ b/include/sta/debug_serial.hpp @@ -3,9 +3,9 @@ * * Configuration: * STA_DEBUG_SERIAL_ENABLE: Enable module - * STA_DEBUG_SERIAL_DISABLE: Forces module off when defined - * DEBUG: Automatically enables module when defined - * NDEBUG: Forces module off when defined + * STA_DEBUG_SERIAL_FORCE: Ignore debug defines and always enable output + * DEBUG: Enables output when defined + * NDEBUG: Disables output when defined (overrides DEBUG) * * The `sta::DebugSerial` instance must be provided. * NOTE: Include this header before the definition because @@ -17,17 +17,15 @@ #include -#ifdef DEBUG -# ifndef STA_DEBUG_SERIAL_ENABLE -# define STA_DEBUG_SERIAL_ENABLE -# endif // !STA_DEBUG_SERIAL_ENABLE -#endif // DEBUG - -#if defined(NDEBUG) || defined(STA_DEBUG_SERIAL_DISABLE) -# ifdef STA_DEBUG_SERIAL_ENABLE -# undef STA_DEBUG_SERIAL_ENABLE -# endif // STA_DEBUG_SERIAL_ENABLE -#endif // NDEBUG || STA_DEBUG_SERIAL_DISABLE +// Check only if STA_DEBUG_SERIAL_FORCE is not defined +#ifndef STA_DEBUG_SERIAL_FORCE +// Disable module if NDEBUG is defined or DEBUG is not +# if defined(NDEBUG) || !defined(DEBUG) +# ifdef STA_DEBUG_SERIAL_ENABLE +# undef STA_DEBUG_SERIAL_ENABLE +# endif // STA_DEBUG_SERIAL_ENABLE +# endif // NDEBUG || !DEBUG +#endif // !STA_DEBUG_SERIAL_FORCE #ifdef STA_DEBUG_SERIAL_ENABLE