I am wanting to report the compile time values of A, B and C as set in the below by way of example -But that doesn't work for the 'enum' defined values, only '#define', both GCC for Pi and for Pico ...I am trying to port code similar to below but far more complicated -To a far more elegant -And, to make sure my porting is correct, that I haven't messed-up any conditionals, I'd like to know and prove that 'TOTAL' has the correct value, same as it was in the non-ported code. How should I do that ?
Code:
#define XTR(x) # x#define STR(x) XTR(x)enum { A, // 0 B, // 1};#define C 2#pragma message "A = " STR(A)#pragma message "B = " STR(B)#pragma message "C = " STR(C)
Code:
x.c:12:9: note: #pragma message: A = Ax.c:13:9: note: #pragma message: B = Bx.c:14:9: note: #pragma message: C = 2
Code:
#if WANT_A #if WANT_B #define A 0 #define B 1 #define TOTAL 2 #else #define A 0 #define TOTAL 1 #endif#else #define TOTAL 0#endif
Code:
enum { #if WANT_A A, #if WANT_B B, #endif #endif TOTAL};
Statistics: Posted by hippy — Sat Mar 16, 2024 6:46 pm