[lkml]   [2001]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: asm/unistd.h
On Thu, 5 Apr 2001, Joseph Carter wrote:

> On Thu, Apr 05, 2001 at 09:06:20AM -0400, Bart Trojanowski wrote:
> > So you ask: "why not just use a { ... } to define a macro". I don't
> > remember the case for this but I know it's there. It has to do with a
> > complicated if/else structure where a simple {} breaks.
> This doesn't follow in my mind. I can't think of a case where a { ... }
> would fail, but a do { ... } while (0) would succeed. The former would
> also save a few keystrokes.

Tim Waugh already stated this one:

#define foo(x) { do_something(x) }

if( condition )

would produce

if( condition )
{ do_something(x) };
{ do_something(y) };

note the semi-colon at the end of {.*}.

This is bad because it forces you to use the foo macro knowing it's a
macro and not a function.

So you say I will use it like this:

if( condition )

That's just great for this case, but now imagine that on some other
architecture doing foo(x) takes many many lines with recursion and all.
You don't want that to be in a macro so you make a function. And you get
many many compiler errors on thsi new platform.



To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:24    [W:0.059 / U:9.756 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site