Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

debug.h

Go to the documentation of this file.
00001 /*
00002  *  File:       debug.h
00003  *              $Id: debug.h,v 1.4 2002/04/29 09:34:10 alec Exp $
00004  *
00005  *  Author:     Alec Panovici (alecu@email.com)
00006  *  Copyright
00007  * 
00008  *  Comments: debug support. Both C and C++ versions. This uses the DEBUG
00009  *  macro from config.h. 
00010  *
00011  *  Revision history:
00012  *
00013  *  $Log: debug.h,v $
00014  *  Revision 1.4  2002/04/29 09:34:10  alec
00015  *  scanner ptree building compiles
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 /* __cplusplus */
00042 
00043 #else /* no DEBUG */
00044 
00045 #define ASSERT(x, y)
00046 #define UNIMPLEMENTED
00047 
00048 
00049 #endif /* DEBUG */
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 /* #ifndef __DEBUG_H__ */

Generated at Tue Jul 9 21:05:43 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001