Those quotes are the source of your current problem, as it expands to:Code:
#define DEBUG_PRINTF "Serial2.printf"
Code:
"Serial2.printf"("hello world\n");
Getting it is easy, problem is what to put inside it unless your Serial2 object has a vprintf() (or vfprintf()) in it.Can you suggest how I get a generalised DEBUG_PRINTF function call using inline fns?
Code:
static inline void DEBUG_PRINTF(const char *fmt, ...){ va_list ap; va_start(ap, fmt); vprintf(fmt, ap); va_end(ap);}
Another approach (untested) using a constant function pointer which should optimise away just like inline:
Code:
typedef void (*printf_ptr)(const char *fmt, ...);static const printf_ptr DEBUG_PRINTF =#if whateverSerial1.printf;#elseSerial2.printf;#endif
Statistics: Posted by arg001 — Fri Nov 22, 2024 11:11 am