rtems/src/scheduler* code convention issue
Joel Sherrill
joel.sherrill at OARcorp.com
Thu May 29 22:09:00 UTC 2014
On 5/29/2014 4:47 PM, Gedare Bloom wrote:
> On Thu, May 29, 2014 at 5:34 PM, Peter Dufault <dufault at hda.com> wrote:
>> On May 28, 2014, at 15:19 , Gedare Bloom <gedare at 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.
Whether it was allowed or not, the original code was just not written to
do that.
And whether we want to do it now or not is a separate issue.
I really don't care.
> -Gedare
>
>> Peter
>> -----------------
>> Peter Dufault
>> HD Associates, Inc. Software and System Engineering
>>
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the devel
mailing list