Main Page | Class List | File List | Class Members | File Members | Related Pages

debug.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *            debug.h
00003  *
00004  *  Tue Oct  5 11:27:20 2004
00005  *  Copyright  2004  Alliance MCA
00006  *  Written by : Antoine Calando (antoine@alliancemca.net)
00007  ****************************************************************************/
00008 
00009 /*
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024  
00034 #ifndef _DEBUG_H
00035 #define _DEBUG_H
00036 
00037 /*************** types ************************/
00038 #include <sys/types.h>
00039 
00040 #ifndef __cplusplus
00041 /*      typedef unsigned short int bool;
00042         #ifndef true
00043                 #define true 1
00044         #endif
00045         #ifndef false
00046                 #define false 0
00047         #endif*/
00048 #endif //__cplusplus
00049 /*typedef unsigned char uchar;*/
00050 #ifndef NULL
00051         #define NULL 0
00052 #endif
00053 
00054 /******************** Debugging stuff ******************/
00055 
00056 #ifndef UT_DEBUG
00057 #define UT_DEBUG 1
00058 #endif
00059 
00060 #if UT_DEBUG>=1
00061 #define DBG1(msg, args...) \
00062         { fprintf(stderr, "DEBUG %s:%d: "  msg  "\n", __FILE__, __LINE__, ## args); }
00063 #else
00064 #define DBG1(msg, args...)
00065 #endif
00066         
00067 #if UT_DEBUG>=2
00068 #define DBG2(msg, args...) \
00069         { fprintf(stderr, "DEBUG %s:%d: "  msg  "\n", __FILE__, __LINE__, ## args); }
00070 #else
00071 #define DBG2(msg, args...)
00072 #endif
00073 
00074 #if UT_DEBUG>=3
00075 #define DBG(msg, args...) DBG3(msg, ## args)
00076 #define DBG3(msg, args...) \
00077         { fprintf(stderr, "DEBUG %s:%d:"   msg  "\n", __FILE__, __LINE__, ## args); }
00078 #define DBG3_S(msg, args...) \
00079         { fprintf(stderr, msg, ## args); }
00080 
00081 #else
00082 #define DBG(msg, args...)
00083 #define DBG3(msg, args...)
00084 #define DBG3_S(msg, args...)
00085 #endif
00086 
00087 #if UT_DEBUG>=1
00088 #define ASSERT(expr) \
00089         if(!(expr)) { \
00090                 fprintf(stderr, "\nASSERT %s:%d: ******* Assertion "  #expr  " failed! ******* \n", __FILE__, __LINE__); \
00091         }
00092 #define ASSERT_MSG(expr, msg, args...) \
00093         if(!(expr)) { \
00094                 fprintf(stderr, "\nASSERT %s:%d: ******* Assertion "  #expr  " failed!" msg " ******* \n", __FILE__, __LINE__, ## args); \
00095         }
00096 #define ERROR(msg, args...) \
00097         { fprintf(stderr, "ERROR %s:%d:"   msg  "\n", __FILE__, __LINE__, ## args); \
00098         exit (-1); }
00099 #else
00100 #define ASSERT(expr)
00101 #define ASSERT_MSG(expr, msg, args...)
00102 #define ERROR(msg, args...)
00103 #endif
00104 
00105 
00106 
00107 #endif /* _DEBUG_H */

Generated on Fri Feb 25 18:30:15 2005 for Utrac by  doxygen 1.3.9