[Top][All Lists]

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

Re: [avr-gcc-list] Inline functions vs. defined macros

From: J Wunsch
Subject: Re: [avr-gcc-list] Inline functions vs. defined macros
Date: Mon, 7 May 2001 16:56:57 +0200 (MET DST)

"Harald Kipp" <address@hidden> wrote:

> Is there any advantage of macros vs. static inline functions?

They are better debuggable.  Of course, this is a moot point for AVR
unless you've got the gdb support up & running.

They perform argument type checking.

They never risk to evaluate their arguments more than once.  Suppose a
poor implementation of tolower():

#define tolower(c) (((c) >= 'A' && (c) <= 'Z')? (c) ^ ('A'-'a'): (c))

....and now imagine that someone would call it like:

       char *cp, x;

       x = tolower(*cp++);

Now you might imagine why it could be important to evaluate arguments
only once. ;-)

> The only one I can imagine is compatibility.

For the AVR, there's IMHO only one other compiler to maintain
compatibility with (and we are IMHO already incmopatible enough, in
particular in library land), so who cares?  Also, C++ has standardized
`inline', it's been a very common extension for C compilers for years
now, and if a target compiler doesn't support it, you'll quickly
notice it as a compile-time error.

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]