On Thu, May 29, 2014 at 5:34 PM, Peter Dufault <dufa...@hda.com> wrote: > > On May 28, 2014, at 15:19 , Gedare Bloom <ged...@rtems.org> wrote: > >>> + It declares new variables in inner scopes which has been avoided >>> in the past. I think this was not supported in older C standards and thus >>> there was no choice but to avoid it. I don't remember when it got added >>> to C. I assume C99 since that is our target language. But we never >>> discussed it. >>> >> I believe I have seen this creeping into RTEMS recently. The coding >> conventions say to use ANSI C, which is a vague description that could >> mean C99, or C90. > > By "declaring variables in inner scopes" are you talking about block scope, > that is, > int foo(void) > { > /* And then later on... */ > > { > int new_scope_var; > ... > } > } > where "new_scope_var" is only in existence in that block? > > I think that's been around close to forever and it shouldn't be discouraged. > Historically macros depend on it, and a coding convention that says "declare > a variable in as restricted a scope as possible" is a MUCH better convention > than avoiding new variables in block scope. > > Sorry if I misunderstood. > 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.
-Gedare > Peter > ----------------- > Peter Dufault > HD Associates, Inc. Software and System Engineering > _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel