Debug TRACE() with variadic arguments
Define :
#ifdef DEBUG
#define TRACE(...) printf("DBG MESSAGE: " __VA_ARGS__)
#else
#define TRACE(...)
#endif
and then in program, you can use something like :
TRACE("my_array[%d]=%x\n", i , arr_val);
All the argument from TRACE() will be taken and substitued in the place of __VA_ARGS__, which will make printf to work well and print this message, with sentence DBG MESSAGE: in the begining.

#ifdef DEBUG
#define TRACE(...) printf("DBG MESSAGE: " __VA_ARGS__)
#else
#define TRACE(...)
#endif
and then in program, you can use something like :
TRACE("my_array[%d]=%x\n", i , arr_val);
All the argument from TRACE() will be taken and substitued in the place of __VA_ARGS__, which will make printf to work well and print this message, with sentence DBG MESSAGE: in the begining.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home