| Revision 1 (by moose, 2006/07/06 01:31:16) |
Initial import
|
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include <stdlib.h>
#include <stdio.h>
#include "platform.h"
#ifdef DEBUG
#define Assert(a) do{ \
if(!(a)) \
error("Assert Failed: %s", " " # a); \
}while(0)
#define warn(a, b...) do{ \
char *__tmp__; \
asprintf(&__tmp__, a, ##b); \
fprintf(stderr, "%s:%s:%i Warning: %s\n", __FILE__, __FUNCTION__, __LINE__, __tmp__); \
}while(0)
#else
#define Assert(a) (void)0
#define warn(a, b...) (void)0
#endif
#define error(a, b...) do{ \
char *__tmp__; \
asprintf(&__tmp__, a, ##b); \
fprintf(stderr, "%s:%s:%i ERROR: %s\n", __FILE__, __FUNCTION__, __LINE__, __tmp__); \
fflush(stderr); \
exit(-1); \
}while(0)
#endif /* __DEBUG_H__ */