I did not find a way to merge the first printf into the second:
unsigned get_time_now(void) {return 1;}
#define DEBUG_PRINT 1
#define debug_tcprintf(fmt, ...) do { \
if (DEBUG_PRINT) { \
unsigned p_time_now = get_time_now(); \
printf ("%u ms ", p_time_now); \
printf(fmt, __VA_ARGS__); \
} \
} while (0)
I need to do this to get atomic debug_tcprintf. The above macro was taken from this stack overflow question .
I am making code in XC that runs on a multi-core XMOS processor. It compiles XC, C, and C ++, but the sample code is from part of the C code. This is similar to XC, except that it has a timer defined in the language.
If it is not possible to combine the two in one printf, perhaps this could be an option to create a string and use sprintf instead? I would prefer, since such an array can easily overflow.