From a995fb77749ff034464353533253ca2ac54ac08c Mon Sep 17 00:00:00 2001 From: Michel Pollet Date: Wed, 6 Nov 2013 14:50:32 +0000 Subject: [PATCH] mmcu: Tweak to the macros to allow multiple declarations This trick adds the line number in the declaration of the fake 'variable' to allows multiple declarations to coexists, it is used for the pullup/down declaration in particular Signed-off-by: Michel Pollet --- simavr/sim/avr/avr_mcu_section.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/simavr/sim/avr/avr_mcu_section.h b/simavr/sim/avr/avr_mcu_section.h index ddef0b6..b153bc3 100644 --- a/simavr/sim/avr/avr_mcu_section.h +++ b/simavr/sim/avr/avr_mcu_section.h @@ -105,9 +105,16 @@ struct avr_mmcu_vcd_trace_t { .len = sizeof(_str),\ .string = _str,\ } +/* + * This trick allows contatenation of tokens. We need a macro redirection + * for it to work. + * The goal is to make unique variable names (they don't matter anyway) + */ +#define DO_CONCAT2(_a, _b) _a##_b +#define DO_CONCAT(_a, _b) DO_CONCAT2(_a,_b) #define AVR_MCU_LONG(_tag, _val) \ - const struct avr_mmcu_long_t _##_tag _MMCU_ = {\ + const struct avr_mmcu_long_t DO_CONCAT(DO_CONCAT(_, _tag), __LINE__) _MMCU_ = {\ .tag = _tag,\ .len = sizeof(uint32_t),\ .val = _val,\ -- 2.39.5