perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jan Dubois" <j...@activestate.com>
Subject RE: simplify mod_perl.c a bit
Date Sun, 04 Apr 2010 04:32:48 GMT
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.

Cheers,
-Jan



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@perl.apache.org
For additional commands, e-mail: dev-help@perl.apache.org


Mime
View raw message