00001 /// \file CATDebug.h 00002 /// \brief Debugging utility functions 00003 /// \ingroup CAT 00004 /// 00005 /// Copyright (c) 2003-2007 by Michael Ellison. 00006 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00007 /// 00008 // $Author: mikeellison $ 00009 // $Date: 2008-01-19 19:19:35 -0600 (Sat, 19 Jan 2008) $ 00010 // $Revision: $ 00011 // $NoKeywords: $ 00012 00013 #ifndef _CATDebug_H_ 00014 #define _CATDebug_H_ 00015 00016 // Include our basic types 00017 #include "CATTypes.h" 00018 00019 // Build reminders 00020 #define __CATEXPSTRING__(x) #x 00021 #define __CATSTRINGCONV__(x) __CATEXPSTRING__(x) 00022 #define __CATLOCINFO__ __FILE__ "("__CATSTRINGCONV__(__LINE__)") : " 00023 00024 /// The CATREMINDER macro is used with pragma to print out a reminder 00025 /// during compile that you can click on from the Visual Studio 00026 /// interface to go to the code that generated it. 00027 /// 00028 /// It's useful for leaving todo's and such 00029 /// in the code. The __CAT*__ macros above it are to jump through 00030 /// the hoops required to convert the __LINE__ macro into 00031 /// a line number string. 00032 /// 00033 /// Usage: pragma CATREMINDER("Fix this.") 00034 #define CATREMINDER(x) message (__CATLOCINFO__ x) 00035 00036 00037 // Compile out assertions and traces 00038 #ifdef CAT_DEBUG 00039 /// CATASSERT() halts the program while running if the expression fails. 00040 /// 00041 /// It differs from traditional assertions in that on some supported 00042 /// platforms we're supporting ignoring them at runtime and try to 00043 /// provide a nice interface. 00044 /// 00045 #define CATASSERT(exp,msg) \ 00046 (void)( (exp) || (_CATAssert(#exp, __FILE__, __LINE__, msg), 0) ) 00047 00048 /// CATTrace() generates a trace message to the output debugging stream. 00049 /// In some applications, this will be a console window. Others, it may 00050 /// just be the debugger output or even a printf. 00051 #define CATTRACE(msg) _CATTrace(msg,__FILE__,__LINE__) 00052 #else 00053 #define CATASSERT(exp,msg) (void(0)) 00054 #define CATTRACE(msg) (void(0)) 00055 #endif 00056 00057 /// _CATAssert() is the root implementation of the CATASSERT() macro. 00058 /// Do not use this directly - instead use CATASSERT(). 00059 void _CATAssert( const char* expression, 00060 const char* file, 00061 CATUInt32 lineNumber, 00062 const char* msg); 00063 00064 /// _CATTrace() is the root implementation of the CATTrace() macro. 00065 /// Do not use this directly - instead use CATTrace() 00066 void _CATTrace( const char* msg, 00067 const char* file, 00068 CATUInt32 line); 00069 00070 00071 #endif // _CATDebug_H_ 00072 00073