add underscore to _DEBUG user macro

This commit is contained in:
bumbread 2022-08-07 20:41:49 +11:00
parent ee2b02a5c4
commit 09fbcb4be3
2 changed files with 4 additions and 4 deletions

View File

@ -14,16 +14,16 @@ The macro checks whether `expr` is true, and if not, prints the
diagnostic information and then aborts execution in a way equivalent to calling diagnostic information and then aborts execution in a way equivalent to calling
abort() function (See SIGABRT). abort() function (See SIGABRT).
If DEBUG macro is defined, assert does not print a diagnostic message, and If `_DEBUG` macro is defined, assert does not print a diagnostic message, and
instead simply causes a debug break. instead simply causes a debug break.
If NDEBUG macro is defined assert expands to an empty statement. If both NDEBUG If NDEBUG macro is defined assert expands to an empty statement. If both NDEBUG
and DEBUG are defined, then DEBUG macro is ignored. and `_DEBUG` are defined, then `_DEBUG` macro is ignored.
```c ```c
#if defined(NDEBUG) #if defined(NDEBUG)
#define assert(expr) ((void)0) #define assert(expr) ((void)0)
#elif defined(DEBUG) #elif defined(`_DEBUG`)
#define assert(expr) /* debug break */ #define assert(expr) /* debug break */
#else #else
#define assert(expr) /* print diagnostic, then abort */ #define assert(expr) /* print diagnostic, then abort */

View File

@ -14,7 +14,7 @@ void _assert(
#if defined(NDEBUG) #if defined(NDEBUG)
#define assert(ignore) ((void)0) #define assert(ignore) ((void)0)
#elif defined(DEBUG) #elif defined(_DEBUG)
#if __GNUC__ #if __GNUC__
#define assert(c) if (!(c)) __builtin_trap() #define assert(c) if (!(c)) __builtin_trap()
#elif _MSC_VER #elif _MSC_VER