Greetings
I have a problem with stringification of a pre-processor macro.
#define FAST_SIN_PHASE_RESOLUTION 1024 #define PZT_TICK_FREQ_TO_FASTSIN_RES_SHIFTS 2 #define PZT_TICK_PERIOD (FAST_SIN_PHASE_RESOLUTION << PZT_TICK_FREQ_TO_FASTSIN_RES_SHIFTS) #define PZT_DUAL_MAX_FREQ (PZT_TICK_PERIOD/2) #define xstr(s) str(s) #define str(s) #s // ... service_init_decimal_input(pState, service_fsm_get_frequency, PSTR("Enter frequency (0 to " xstr(PZT_DUAL_MAX_FREQ) " Hz): "), 0, PZT_DUAL_MAX_FREQ);
When compiled I get this assembly output:
__c.1863: .string "Enter frequency (0 to ((1024 << 2)/2) Hz): "
which is obviously not quite what I want. The line should say "... (0 to 2048 Hz):".
I tried defining more levels of xstr macros:
#define xstr3(s) xstr2(s) #define xstr2(s) xstr(s) #define xstr(s) str(s) #define str(s) #s
but neither will give me the fully evaluated expression in the string. How can I achieve this?
ATMEL Studio 7.0.1006
GCC: (AVR_8_bit_GNU_Toolchain_3.5.3_1700) 4.9.2