[lkml]   [2001]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: asm/unistd.h
On Thu, Apr 05, 2001 at 09:58:43AM -0300, Sarda?ons, Eliel wrote:
> I'm taking a look at the linux code and I don't understand how do you
> programm...mmm (?) may be i'm a stupid why in include/asm/unistd.h in some
> macros you use this:
> do {
> ...
> } while (0)

Imagine a macro of several lines of code like:

#define FOO(x) \
printf("arg is %s\n", x); \

Now imagine using it like:

if (blah == 2)

This interprets to

if (blah == 2)
printf("arg is %s\n", blah);

As you can see, the "if" then only encompasses the printf, and the
do_something_useful() call is unconditional (not within the scope of the
if), like you wanted it.

So, by using a block like do{...}while(0), you would get this:

if (blah == 2)
do {
printf("arg is %s\n", blah);
} while (0);

Which is exactly what you want.

/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` -- -- '
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.134 / U:1.692 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site