xprintf d727b10
|
Debug routines. More...
Functions | |
int | debugNonl (const char *format,...) __attribute__((format(printf |
Prints a message to a debug channel, like fprintf() would. | |
int int | debugnl (const char *format,...) __attribute__((format(printf |
Prints a message to a debug channel, followed by a newline (CR,NL to please MS users). | |
int int int | debugNL (void) |
Prints a newline to a debug channel (CR,NL to please MS users). | |
int | debugF3 (int64_t value, int divider) |
Prints value/divider with sign in 3 decimals, as if with a "%+.3f" format. | |
int | debugStringF3 (const char *s, int64_t value, int divider) |
Prints string s immediately followed by value/divider with sign in 3 decimals, as if with a "%s%+.3f" format. | |
int | debugF3nl (int64_t value, int divider, const char *format,...) |
Prints a formatted debug message followed by a colon, a space, value/divider with sign in 3 decimals and a newline. |
Debug routines.
The include file xdebug-masterswitch.h sets two preprocessor defines: DEBUG_ENABLED
and DEBUG_DISABLED
to 0 and 1 or to 1 and 0, respectively.
If flagged to disable debug calls (DEBUG_DISABLED==1
, DEBUG_ENABLED==0
), this module provides dummy static
inline
bodies for the debug functions so that compile-time checks are still done but no code is generated:
static inline int debugnl(const char *format, ...) { (void) format; // prevent compiler error "unused parameter 'format'" return 0; }
Compare the dummy static
inline
body to a #define
that skips the compile-time checks:
#define debugnl(...) (0) // no code, but also no compile-time checks
Try it out and compare the code size: the compiler is clever enough to generate no code for the dummy static
inline
body.
int debugF3 | ( | int64_t | value, |
int | divider | ||
) |
Prints value/divider
with sign in 3 decimals, as if with a "%+.3f" format.
value | any |
divider | should be >0:if ≤0 will print value as integer followed by "/" divider |
int debugF3nl | ( | int64_t | value, |
int | divider, | ||
const char * | format, | ||
... | |||
) |
Prints a formatted debug message followed by a colon, a space, value/divider
with sign in 3 decimals and a newline.
If arg format
is null, behaves identical to debugF3().
format | printf()-style format |
... | printf()-style arguments to match the format |
value | any |
divider | should be >0:if ≤0 will print value as integer followed by "/" divider |
int int debugnl | ( | const char * | format, |
... | |||
) |
Prints a message to a debug channel, followed by a newline (CR,NL to please MS users).
format | printf()-style format |
int int int debugNL | ( | void | ) |
Prints a newline to a debug channel (CR,NL to please MS users).
int debugNonl | ( | const char * | format, |
... | |||
) |
Prints a message to a debug channel, like fprintf()
would.
format | printf()-style format |
... | printf()-style arguments to match the format |
int debugStringF3 | ( | const char * | s, |
int64_t | value, | ||
int | divider | ||
) |
Prints string s
immediately followed by value/divider
with sign in 3 decimals, as if with a "%s%+.3f" format.
If arg s
is null, behaves identical to debugF3().
s | string pointer |
value | any |
divider | should be >0:if ≤0 will print value as integer followed by "/" divider |