>
> #define SWITCH_CH1() { P4OUT &= ~(BIT4+BIT5+BIT6); }
>
> This does work:
>
> void SWITCH_CH1 (void)
> {
> P4OUT &= ~(BIT4+BIT5+BIT6);
> }
Well, I'd expect those to behave differently if you had a statement
like:
if (PINB & 1)
SWITCH_CH1();
else
PORTD = 0;
while(1); }
But I'd expect (and I get) compiler errors ("else without if
statement")
when
the macro version is used.
I don't know offhand where such code would be silently accepted and
end up resulting in removed code, but it wouldn't surprise me if such
a syntax existed.
Whenever you have fancy macros that behave unexpectedly, it can pay to
look at the preprocessor output for your program ("-E") as well as
the
listing
of the final code. Modern C code tends to include a lot of macros that
obscure
such a listing, but ...
BillW
Functions not working after optimization in IAR
Started by ●February 8, 2012