00001 // $Revision: 1.4 $ $Author: schwehr $ $Date: 2004/12/24 23:05:45 $ 00002 /* 00003 Copyright (C) 2004 Kurt Schwehr 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 */ 00021 00025 00026 // Thanks to Dan Christian and Dave Wettergreen getting me hooked on 00027 // the debug level stuff. 00028 // 00029 // I know, I am mixing both cout and printf. It seems to work for 00030 // me! 00031 00032 00033 #ifndef _DEBUG_H_ 00034 #define _DEBUG_H_ 00035 00036 00037 #ifdef __GNUC__ 00038 #define UNUSED __attribute((__unused__)) 00039 #else 00040 00047 #define UNUSED 00048 #endif 00049 00050 #ifdef REGRESSION_TEST 00051 #define FAILED_HERE cout << __FILE__ << ":" << __LINE__ \ 00052 << " failed in function " << __FUNCTION__ << endl 00053 #else 00054 00058 #define FAILED_HERE // Empty 00059 #endif 00060 00061 00062 /* Debugging levels... the higher the # the more output you get. */ 00063 // FIX: will these clash when we link other files with this in? foo.o and bar.o both use debug.h? 00064 const int ALWAYS=0; 00065 const int TERSE=1; 00066 const int TRACE=4; 00067 const int VERBOSE=8; 00068 const int BOMBASTIC=20; 00069 00070 #ifdef NDEBUG 00071 # define DebugPrintf(n,s) /* expand to nothing */ 00072 #else 00073 00074 extern int debug_level; 00076 # define DebugPrintf(n,s) (((n) <= debug_level) ? printf s :0) 00077 #endif 00078 00079 00080 #endif // _DEBUG_H_