Skip to content

Commit

Permalink
DebugLib: Simplify DEBUG macro used when MDEPKG_NDEBUG is defined
Browse files Browse the repository at this point in the history
The variant used when MDEPKG_NDEBUG is defined will be optimised
away in RELEASE builds, but by referencing the argument list, avoids
unused variable errors from valid debug code, for example when STATIC
variables are used only in DEBUG statements.
  • Loading branch information
mikebeaton committed Dec 13, 2023
1 parent 8023b33 commit 2bba588
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions MdePkg/Include/Library/DebugLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,18 +433,13 @@ UnitTestDebugAssert (
_DEBUG (Expression); \
} \
} while (FALSE)
#elif defined (__GNUC__) || defined (__clang__)
#define DEBUG(Expression) \
do { \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wunused-value\"") \
if ((FALSE)) { \
(VOID) Expression; \
} \
_Pragma("GCC diagnostic pop") \
} while (FALSE)
#else
#define DEBUG(Expression)
#define DEBUG(Expression) \
do { \
if (FALSE) { \
_DEBUG (Expression); \
} \
} while (FALSE)
#endif

/**
Expand Down

0 comments on commit 2bba588

Please sign in to comment.