avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] port access with avr-gdb


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] port access with avr-gdb
Date: Fri, 18 Jun 2004 11:15:16 +0200 (MET DST)

"David Brown" <address@hidden> wrote:

> What sort of portability are you looking for?  Being able to take a
> program for an AVR and run it unaltered on an MSP430?  Being able to
> take a program for gcc-avr and being able to compile it unaltered on
> iar-avr?

The way the macros are currently arranged matches the way Atmel uses
in their datasheets (which has most certainly been influenced by the
way IAR does it).  There are still enough further compatibility issues
between IAR and GCC, sure (notably GCC's missing ability to handle
memory sections automagically), but the direct assignment of IO
registers helps quite a bit (together with using the exact register
names as described in Atmel's datasheets).

> Multi-line macros using "do {...} while (0)" are definitely archaic.
> They are ugly to write, inconvenient to maintain (you need a \ at
> the end of the lines, making them different from every other line),
> unclear to read (especially for a newbie) - what exactly is the
> point of a "while (0)" loop?  I know it is there so that someone can
> safely write "if (starting) motor_init();" but it is not exactly a
> clear, understandable construct.  Why not write them as static
> inline functions:

Well, beginners do not need to maintain them. ;-)

Be careful, sometimes GCC opts to /not/ inline a function where you
requested it.  There's an __attribute__ where you can force it, but
that'll make it almost as unreadable as the do { } while(0) construct.

After all, the do { } while (0) trick is well-known to any seasoned C
programmer, too.

-- 
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/


reply via email to

[Prev in Thread] Current Thread [Next in Thread]