Re: do {} while(0)

Jan-Simon Pendry (jsp@ms.com)
Mon, 28 Jun 1999 10:02:06 +0100


"David S. Miller" wrote:
>
> Date: Mon, 28 Jun 1999 16:20:07 +0800
> From: wu_yb <wu_yb@263.net>
>
> Any difference between {} and do {} while(0); or
> { ... } and do {...} while(0). Are there any
> special effect ?
>
> Avoids "empty statement" warnings from the compiler.

also, consider:

#define a() { i = 1; j = 2; }
#define b() do { i = 1; j = 2; } while (0)
#define c() x()

f() {
int i, j;

if (1) a(); else c();
if (1) b(); else c();
}

the first if statement results in a syntax error.

jan-simon.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/