util: add debug_warn_once() macro

Emits a warning message, but only once to avoid tons of repeated warnings.
This commit is contained in:
Brian Paul 2012-01-07 14:16:27 -07:00
parent 994c33db87
commit 94bf2d48e1
1 changed files with 19 additions and 0 deletions

View File

@ -214,6 +214,25 @@ void _debug_assert_fail(const char *expr,
#endif
/**
* Emit a warning message, but only once.
*/
#ifdef DEBUG
#define debug_warn_once(__msg) \
do { \
static bool warned = FALSE; \
if (!warned) { \
_debug_printf("%s:%u:%s: one time warning: %s\n", \
__FILE__, __LINE__, __FUNCTION__, __msg); \
warned = TRUE; \
} \
} while (0)
#else
#define debug_warn_once(__msg) \
((void)0)
#endif
/**
* Output an error message. Not muted on release version.
*/