On 2010-04-03, at 11:32 PM, Jan Dubois wrote:
> On Sat, 03 Apr 2010, Randy Kobes wrote:
>> On 2010-04-03, at 8:39 PM, Philip M. Gollucci wrote:
>>
>>> What ANSI C std is that?
>>>
>>> perl core code and fbsd code do this all over the place. They are
>>> supposedly C-99.
>>
>>> On 4/2/2010 4:40 PM, Philippe M. Chiasson wrote:
>>>>
>>>> In ANSI C you can't define variables in blocks, like
>>>>
>>>> int foo(void) {
>>>> int a = 2;
>>>> some code
>>>> {
>>>> int b = 3;
>>>> more code
>>>> }
>>>>
>>>> So the below patch fixes that by making the rc status variable global
>>>> to the function. I compile with -Wall -Werror and it tends to pick these
>>>> up.
>>
>> I'm not sure about the standards, but VC++ on Windows definitely
>> doesn't like code coming before declarations in a function like in
>> the above.
>
> I think you are confused here. The code above will definitely work
> fine with VC. What *doesn't* work is mixing declarations and
> executable code inside the *same* scope. Declarations always have
> to come at the top of the new scope before any executable code.
> Whenever you introduce a new nested scope you can declare additional
> variables.
>
> C99 removes this restriction (and C++ never had it), but the Perl core
> code definitely doesn't require C99; it compiles with VC just fine.
Thanks for clearing that up - I was forgetting about the admissibility of
declarations within a scope.
--
best regards,
Randy
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]