do { ... } while(0) v kernelovem kodu
Martin Mares
mj na ucw.cz
Sobota Leden 2 20:29:57 CET 1999
Zdravim,
> Muze mi nekdo, prosim, sdelit, proc je v kernelovem kodu obcas pouzita
> konstrukce
> do {
> ..
> } while(0)
>
> Proc nestaci jen:
> {
> ...
> }
Protoze to neni to same, pokud tuto konstrukci pouziji uvnitr makra, od ktereho
ocekavam, ze se bude chovat jako normalni funkce. Napriklad:
#define FOO() { a(); b(); }
if (1) FOO(); else c();
fungovat nebude, zatimco pouziji-li
#define FOO() do { a(); b(); } while (0)
bude vse v poradku.
Have a nice fortnight
--
Martin `MJ' Mares <mj na ucw.cz> http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"Man is the highest animal. Man does the classifying."
Další informace o konferenci Linux