[Change] WARN and ERR now generate asserts in debug mode.

This commit is contained in:
Allanis 2013-08-19 23:27:47 +01:00
parent 028f77f78a
commit a234593091
2 changed files with 9 additions and 2 deletions

View File

@ -14,6 +14,7 @@ Contributors:
* Testing. * Testing.
Past Contributors: Past Contributors:
-- KonoM (Tamir Atias) -- KonoM (Tamir Atias)
* Lazy ass. * Lazy ass.
* Bug Squatter. * Bug Squatter.

View File

@ -1,10 +1,16 @@
#pragma once #pragma once
#include <stdio.h> #include <stdio.h>
/* We'll use asserts in DEBUG if defined. */
#ifndef DEBUG
# define NODEBUG
#endif /* DEBUG */
#include <assert.h>
#define LOG(str, args...)(fprintf(stdout, str"\n", ## args)) #define LOG(str, args...)(fprintf(stdout, str"\n", ## args))
#define WARN(str, args...)(fprintf(stderr, "Warning: "str"\n", ## args)) #define WARN(str, args...)(fprintf(stderr, "Warning: "str"\n", ## args), assert(0))
#define ERR(str, args...) (fprintf(stderr, "ERROR %s:%d: [%s] "str"\n", \ #define ERR(str, args...) (fprintf(stderr, "ERROR %s:%d: [%s] "str"\n", \
__FILE__, __LINE__, __func__, ## args)) __FILE__, __LINE__, __func__, ## args), assert(0))
#ifdef DEBUG #ifdef DEBUG
# undef DEBUG # undef DEBUG