No the original suggestion of (&LED1_DDR == &LED2_DDR) is necessary because
of the way the DDRs are defined (they are the value of register)... the
ampersands get you back to the register address, which is more likely what
you are trying to determine with such a statement.

Vic

On Sun, Jun 3, 2012 at 3:29 PM, Joerg Wunsch <j...@uriah.heep.sax.de> wrote:

> Georg-Johann Lay <a...@gjlay.de> wrote:
>
> >> Could anyone explain this to me? Is there any way around this
> >> (still using macros)?
>
> > With macros? No way here.
>
> Well: no way *at the preprocessor level*.
>
> However, moving the comparison to the *compiler level* could work.
> The values of e.g. DDRD and DDRB are expressions that can be compared
> by the compiler.  As the resulting comparison is constant at
> compile-time, with optimization enabled, those code portions that can
> never be reached (due to the compile-time constant comparisons) are
> optimized away.
>
> So, turn your
>
> #if LED1_DDR == LED2_DDR
>
> into
>
>  if (LED1_DDR == LED2_DDR) {
>    // ...
>  } else {
>    // both DDRs are not the same
>    // ...
>  }
>
> --
> cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL
>
> http://www.sax.de/~joerg/                        NIC: JW11-RIPE
> Never trust an operating system you don't have sources for. ;-)
>
> _______________________________________________
> AVR-GCC-list mailing list
> AVR-GCC-list@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list
>
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to