00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __DEBUG_H__
00020 #define __DEBUG_H__
00021
00022 #include "../config.h"
00023
00024 #ifdef DEBUG
00025
00026 #if defined __cplusplus
00027
00028 #define ASSERT(x, y) {if (!(x)) { cerr << "ASSERTION FAILED @" << __FILE__ << ":" << __LINE__ << ": " << (y) << endl; cerr.flush(); abort(); }}
00029
00030 #define UNIMPLEMENTED {cerr << "UNIMPLEMENTED @" << __FILE__ << ":" << __LINE__ << endl; cerr.flush(); abort(); }
00031
00032 #else
00033
00034 #include <stdio.h>
00035
00036 #define ASSERT(x, y) {if(!(x)) { fprintf(stderr, "ASSERTION FAILED @%s:%d: %s\n", __FILE__, __LINE__, y); fflush(stderr); abort(); }}
00037
00038 #define UNIMPLEMENTED { fprintf(stderr, "UNIMPLEMENTED @%s:%d\n", __FILE__, __LINE__); fflush(stderr); abort(); }}
00039
00040
00041 #endif
00042
00043 #else
00044
00045 #define ASSERT(x, y)
00046 #define UNIMPLEMENTED
00047
00048
00049 #endif
00050
00051 #if defined __cplusplus
00052
00053 #define RUNTIME_ERROR(x) { cerr << "RUNTIME ERROR @" << __FILE__ << ":" << __LINE__ << ": " << (x) << endl; cerr.flush(); abort(); }
00054
00055 #else
00056
00057 #define RUNTIME_ERROR(x) { fprintf(stderr, "RUNTIME ERROR @%s:%d: %s\n", __FILE__, __LINE__, x); fflush(stderr); abort(); }
00058
00059 #endif
00060
00061
00062 #endif