Coldfire (MCF5235) Interrupt Problem

Eric Norum wenorum at lbl.gov
Fri May 11 18:03:26 UTC 2012


On May 11, 2012, at 10:45 AM, Claus, Ric wrote:

> Ditto on "_old_handler".  And I suppose "TPU_INT_VECTOR" is supposed to be "_vector".
> 
> BTW, what is the purpose of the "do {...} while(0)" construct?  I've seen it used several times in RTEMS code and don't understand its purpose.  Is there some side-effect I'm not aware of?  Otherwise, why not use "{...}" by itself to introduce a new scope block?  Please educate me.

The do-while(0) construct is there to allow a multi-statement macro to appear as a single C block  -- note that the macro has no semicolon after the while(0) 
Thus you can use the macro in the body of an if statement like
	if (something)
		theMacro(foo, bar);
	else
		somethingElse();

The above would break with your simple {….}  expansion.



-- 
Eric Norum
wenorum at lbl.gov





More information about the users mailing list