#ifndef DEBUG_H #define DEBUG_H #define PRE(EXPR, PRINTFTEXT) if (!(EXPR)) { printf(PRINTFTEXT); } #define POST(EXPR, PRINTFTEXT) if (!(EXPR)) { printf(PRINTFTEXT); } #define DEBUG #undef DEBUG #define DEBUG #undef DEBUG #ifdef DEBUG #define CURRENT_DEBUGLEVEL 0 #define DEBUG_BEGIN(FUNCTIONNAME, DEBUGLEVEL)\ {\ int i;\ if (DEBUGLEVEL <= CURRENT_DEBUGLEVEL)\ {\ for (i = 0; i < current_indentation; i++)\ printf(" ");\ current_indentation++;\ printf(#FUNCTIONNAME " begins in %s at line %d\n", __FILE__, __LINE__);\ }\ } #define DEBUG_END(FUNCTIONNAME, DEBUGLEVEL)\ {\ int i;\ if (DEBUGLEVEL <= CURRENT_DEBUGLEVEL)\ {\ current_indentation--;\ for (i = 0; i < current_indentation; i++)\ printf(" ");\ printf(#FUNCTIONNAME " finished in %s at line %d!\n",\ __FILE__, __LINE__);\ }\ } #endif #ifndef DEBUG #define DEBUG_BEGIN(FUNCTIONNAME, DEBUGLEVEL) #define DEBUG_END(FUNCTIONNAME, DEBUGLEVEL) #endif #endif