Getting this thread back on topic , I'm trying to use a macro to use Serial.printf or Serial2.printf and again it's a pain in the whole with crazy macro systax issues. I already gave up macro concatenation and did it long hand.Not necessarily relevant here, but nowadays I often use inline functions to achieve the same effect as a macro with much less fighting over the syntax.
Code:
#define SERIAL_PORT // null,1,2: IDE Wire.Serial goes to USB #define UART M_CONC(Serial,SERIAL_PORT) // abandon macro fuckery, too long. #if (SERIAL_PORT+1-1 ==0) #define DEBUG_PRINTF "Serial.printf" #elif (SERIAL_PORT+1-1 ==1) #define DEBUG_PRINTF "Serial1.printf" #else // 2 #define DEBUG_PRINTF "Serial2.printf" #endif
However, this still fails to compile when I use DEBUG_PRINTF :
Code:
error: expression cannot be used as a function 784 | DEBUG_PRINTF("# system clock = %d MHz\n",clock_get_hz(clk_sys)/(1000*1000));
Can you suggest how I get a generalised DEBUG_PRINTF function call using inline fns?
TIA.
Statistics: Posted by pie_face — Fri Nov 22, 2024 10:10 am