Re: do {} while(0)

Wojtek Pilorz (wpilorz@bdk.pl)
Mon, 28 Jun 1999 11:20:56 +0200 (MET DST)


On Mon, 28 Jun 1999, wu_yb wrote:
>
> There are many
> do {} while(0) ;
> do { ... } while(0) ;
> in kernel source.
> Any difference between {} and do {} while(0); or
> { ... } and do {...} while(0). Are there any
> special effect ?
One difference is that within do { ... } while(0) block
you can use break or continue to leave the block (yes, both break and
continue will work the same way here) - a kind of structured goto;
For example of such use, please look at file ipc/shm.c and search for
'while (0)'. Another example is in drivers/video/atafb.c (__initfunc);
In general there are very few examples of such usage in kernel source.

>
> Thanks very much
>
>
Best regards,

-
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/