| Juan Cespedes | cac15c3 | 2003-01-31 18:58:58 +0100 | [diff] [blame^] | 1 | #include <features.h> |
| 2 | |
| 3 | void debug_(int level, char *file, int line, char *func, char *fmt, ...); |
| 4 | |
| 5 | # define debug(level, expr...) debug_(level, __FILE__, __LINE__, DEBUG_FUNCTION, expr) |
| 6 | |
| 7 | /* Version 2.4 and later of GCC define a magical variable `__PRETTY_FUNCTION__' |
| 8 | which contains the name of the function currently being defined. |
| 9 | This is broken in G++ before version 2.6. |
| 10 | C9x has a similar variable called __func__, but prefer the GCC one since |
| 11 | it demangles C++ function names. */ |
| 12 | # if __GNUC_PREREQ (2, 4) |
| 13 | # define DEBUG_FUNCTION __PRETTY_FUNCTION__ |
| 14 | # else |
| 15 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
| 16 | # define DEBUG_FUNCTION __func__ |
| 17 | # else |
| 18 | # define DEBUG_FUNCTION ((__const char *) 0) |
| 19 | # endif |
| 20 | # endif |