51 lines
2.4 KiB
C
51 lines
2.4 KiB
C
|
#ifndef ASSERTIONS_H_
|
||
|
#define ASSERTIONS_H_
|
||
|
|
||
|
#ifdef _MSC_VER
|
||
|
|
||
|
#include <stdio.h>
|
||
|
|
||
|
#define _Assert_(cOND, aCTION, fORMAT, ...) \
|
||
|
do { \
|
||
|
if (!(cOND)) { \
|
||
|
printf("Assertion ("#cOND") failed! "fORMAT"\n", __VA_ARGS__); \
|
||
|
aCTION; \
|
||
|
} \
|
||
|
} while(0)
|
||
|
|
||
|
#define _AssertNoPrint_(cOND, aCTION) \
|
||
|
do { \
|
||
|
if (!(cOND)) { \
|
||
|
aCTION; \
|
||
|
} \
|
||
|
} while(0)
|
||
|
|
||
|
#define AssertError(cOND, aCTION, fORMAT, ...) _Assert_(cOND, aCTION, fORMAT, __VA_ARGS__)
|
||
|
#define AssertErrorNoPrint(cOND, aCTION) _AssertNoPrint_(cOND, aCTION)
|
||
|
|
||
|
#else
|
||
|
|
||
|
#include "pdebug.h"
|
||
|
|
||
|
#define _Assert_(cOND, aCTION, fORMAT, aRGS...) \
|
||
|
do { \
|
||
|
if (!(cOND)) { \
|
||
|
log_error("Assertion ("#cOND") failed! "fORMAT"\n", ##aRGS); \
|
||
|
aCTION; \
|
||
|
} \
|
||
|
} while(0)
|
||
|
|
||
|
#define _AssertNoPrint_(cOND, aCTION) \
|
||
|
do { \
|
||
|
if (!(cOND)) { \
|
||
|
aCTION; \
|
||
|
} \
|
||
|
} while(0)
|
||
|
|
||
|
#define AssertError(cOND, aCTION, fORMAT, aRGS...) _Assert_(cOND, aCTION, fORMAT, ##aRGS)
|
||
|
#define AssertErrorNoPrint(cOND, aCTION) _AssertNoPrint_(cOND, aCTION)
|
||
|
|
||
|
#endif
|
||
|
#endif /* ASSERTIONS_H_ */
|
||
|
|