Mail Archives: djgpp-workers/1998/02/12/06:33:27
Hans-Bernhard Broeker wrote:
> > The macro's I offered were also acceptable. Every library I've seen so
> > far (bo*nd, djgpp, FreeBSD, gnulibc) does offer a set of macro's.
>
> That may well be so, but does that mean we have to follow what is actually
> just a tradition, based in the day when 'inline' functions weren't
> available yet in most compilers?
Not just to follow a tradition, no, unless you are English ;)
> After all, as the gcc docs state it 'an
> inline function is as fast as a macro', but it does have the benefit of
> type-safeness, and automatic demotion to a function call if the compiler
> thinks that's a better idea in a given situation.
Type-safeness is not at order, here, since that yields undefined
behaviour.
> But I didn't mean to imply your macro implementation weren't "acceptable",
> anyway. I just wanted to point a possible alternative. And your
> implementation using the ({ }) syntax is already rather close to an inline
> function, as well, so why not take that final step as well?
There is something nasty about inline externs. You have to put also a
version without 'inline extern' in the libc library. So far, no problem,
but as you have two instances of the same code, your risk that you
forget updating one of them when they need to be modified (not to
mention the little extra work that is involved).
If you have macro version, you can simple include that code in the
function version, and you don't have the hassles for double-modifying
it.
--
\ Vik /-_-_-_-_-_-_/
\___/ Heyndrickx /
\ /-_-_-_-_-_-_/
- Raw text -