Debugging macros
I've put together a set of macros to make debugging easier.
One day I'll learn how to use external debugging software, but until then...
Macros that print messages when the global
tk_debug > level.
PING(level) |
Prints "PING file.line\n". |
MSG(level,...) |
Prints the message ... . |
DUMP(level,a,fmt) |
Dumps a variable a with a given format fmt. |
Macros controlling general error-checking and handling.
CHK(a) |
Fail verbosely if a != SUCCESS |
AST(a) |
Fail verbosely if a == 0 |
E_AST(a, e_code) |
Like AST(), but return e_code instead of FAILURE |
M_AST(a, e_code, ... ) |
Like E_AST(), but also print a message ... |
M_EXIT(e_code, ... ) |
Print a message ... and return e_code. |
Macros for comparison
MIN(a,b) |
Returns the min of a and b (not robust). |
MAX(a,b) |
Returns the max of a and b (not robust). |
Macros that manipulate strings.
STRCAT(a,b) |
Concatenates two strings (not robust). |
C function to test the various macros.
Bash script to put
macro_test.c through its paces.