Fix VGM_ASSERT_ONCE

This commit is contained in:
bnnm 2018-07-21 20:12:40 +02:00
parent dc4cee2daf
commit 1ec9463235

View File

@ -77,14 +77,14 @@ void concatn(int length, char * dst, const char * src);
/* Simple stdout logging for debugging and regression testing purposes. /* Simple stdout logging for debugging and regression testing purposes.
* Needs C99 variadic macros, uses do..while to force ; as statement */ * Needs C99 variadic macros, uses do..while to force ";" as statement */
#ifdef VGM_DEBUG_OUTPUT #ifdef VGM_DEBUG_OUTPUT
/* equivalent to printf when condition is true */ /* equivalent to printf when condition is true */
#define VGM_ASSERT(condition, ...) \ #define VGM_ASSERT(condition, ...) \
do { if (condition) printf(__VA_ARGS__); } while (0) do { if (condition) {printf(__VA_ARGS__);} } while (0)
#define VGM_ASSERT_ONCE(condition, ...) \ #define VGM_ASSERT_ONCE(condition, ...) \
do { static int written; if (!written) { if (condition) printf(__VA_ARGS__); written = 1; } } while (0) do { static int written; if (!written) { if (condition) {printf(__VA_ARGS__); written = 1;} } } while (0)
/* equivalent to printf */ /* equivalent to printf */
#define VGM_LOG(...) \ #define VGM_LOG(...) \
do { printf(__VA_ARGS__); } while (0) do { printf(__VA_ARGS__); } while (0)
@ -110,6 +110,7 @@ void concatn(int length, char * dst, const char * src);
#else/*VGM_DEBUG_OUTPUT*/ #else/*VGM_DEBUG_OUTPUT*/
#define VGM_ASSERT(condition, ...) /* nothing */ #define VGM_ASSERT(condition, ...) /* nothing */
#define VGM_ASSERT_ONCE(condition, ...) /* nothing */
#define VGM_LOG(...) /* nothing */ #define VGM_LOG(...) /* nothing */
#define VGM_LOG_ONCE(...) /* nothing */ #define VGM_LOG_ONCE(...) /* nothing */
#define VGM_LOGF() /* nothing */ #define VGM_LOGF() /* nothing */