rtems/src/scheduler* code convention issue

Peter Dufault dufault at hda.com
Fri May 30 07:43:24 UTC 2014


On May 29, 2014, at 17:47 , Gedare Bloom <gedare at rtems.org> wrote:

> You understood precisely. I think it was not permitted in C90 perhaps?
> We should revisit it, but I think historically all variables are
> declared at the top of the function.

I'll dig up K&R, but I'm 95% sure it's been supported from the beginning.  What hasn't always been supported is declaring variables anywhere other than after an opening bracket:

/* Local block */
{
	invoke_foo();
	int i;
	invoke_bar(&i);
	/* ... */
}

The argument for permitting declaration inside brackets (not as above, but as allowed by K&R) is to declare variables in as restrictive a scope as possible.  The argument against is shadowing variables and getting subtle errors.

Peter
-----------------
Peter Dufault
HD Associates, Inc.      Software and System Engineering





More information about the devel mailing list