From: Michel Pollet Date: Wed, 6 Nov 2013 14:50:32 +0000 (+0000) Subject: mmcu: Tweak to the macros to allow multiple declarations X-Git-Tag: v1.2~57 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=a995fb77749ff034464353533253ca2ac54ac08c;p=sx%2Fsimavr.git 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 --- 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,\