04-17-2005, 06:25 PM
Here's a pair of debug macros, copying c's ASSERT and VB's debug.print.
To use them, write them to .bi file, then include it in your programs. The macros are activated by default. When debug is ended, add
BEFORE the include.
C's ASSERT prints the asserted expression as well , but FB's maceos do not have the "stringize" operator yet.
Question to developers: could be a call to the crt assert function safely used?
I Hope you find them useful...
To use them, write them to .bi file, then include it in your programs. The macros are activated by default. When debug is ended, add
Code:
#DEFINE ndebug
Code:
'debug macros by Antoni Gual
'-----------------------------------------------------------------------------
'ASSERT macro:if not defined ndebug, if assert is false it prints and exits,
'Use ask for a condition that should never happen:
'Example :assert(a<7)
'-----------------------------------------------------------------------------
#ifdef ndebug
#define assert(x) :
#else
#define assert(x) IF NOT (x) THEN ? "Assert failed at line ";__LINE__;" func "; _
__FUNCTION__;" file "; __FILE__:SLEEP:END IF
#endif
'
'-----------------------------------------------------------------------------
'DEBUG_PRINT if not defined ndebug, it prints value and the place where it is
'Example of use; debug_print("a$= ";a$)
'-----------------------------------------------------------------------------
#ifdef ndebug
#define debug_print(x,y) :
#else
#define debug_print(x,y) PRINT (x);(y);" line ";__LINE__;" func ";__FUNCTION__; _
" file ";__FILE__
#endif
C's ASSERT prints the asserted expression as well , but FB's maceos do not have the "stringize" operator yet.
Question to developers: could be a call to the crt assert function safely used?
I Hope you find them useful...
Antoni