xprintf d727b10
xdebug.h File Reference

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.

Detailed Description

Debug routines.

Debugging enable/disable

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.


Function Documentation

int debugF3 ( int64_t  value,
int  divider 
)

Prints value/divider with sign in 3 decimals, as if with a "%+.3f" format.

Parameters:
valueany
dividershould be >0:if ≤0 will print value as integer followed by "/" divider
Returns:
&lt0: error
≥0: number of chars written
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().

Parameters:
formatprintf()-style format
...printf()-style arguments to match the format
valueany
dividershould be >0:if ≤0 will print value as integer followed by "/" divider
Returns:
&lt0: error
≥0: number of chars written
int int debugnl ( const char *  format,
  ... 
)

Prints a message to a debug channel, followed by a newline (CR,NL to please MS users).

Parameters:
formatprintf()-style format
Returns:
&lt0: error
>=0: number of chars written (excluding the added newline)
int int int debugNL ( void  )

Prints a newline to a debug channel (CR,NL to please MS users).

Returns:
&lt0: error
0: success
int debugNonl ( const char *  format,
  ... 
)

Prints a message to a debug channel, like fprintf() would.

Parameters:
formatprintf()-style format
...printf()-style arguments to match the format
Returns:
&lt0: error
>=0: number of chars written
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().

Parameters:
sstring pointer
valueany
dividershould be >0:if ≤0 will print value as integer followed by "/" divider
Returns:
&lt0: error
≥0: number of chars written