delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/14/09:44:07

Date: Fri, 14 Mar 1997 09:38:37 -0500 (EST)
From: "art s. kagel IFMX x2697" <kagel AT dg1 DOT bloomberg DOT com>
To: John Beppu <beppu AT rigel DOT oac DOT uci DOT edu>
Cc: djgpp AT delorie DOT com
Subject: Re: DJGPP inconsistencies?
In-Reply-To: <5g9umf$jaa@news.service.uci.edu>
Message-Id: <Pine.D-G.3.91.970314093726.4515C-100000@dg1>
Mime-Version: 1.0

Actually ANSI "C" permits the declaration of variables at the beginning 
of any code block, ie after the opening brace ({) and before any 
executable code.

Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com

On 13 Mar 1997, John Beppu wrote:

> In article <5g9p1b$fac AT netra DOT montana DOT edu>,
> Paul Peavyhouse <pv AT cs DOT montana DOT edu> wrote:
> 
>     [this didn't work for Paul]
> 
> >DATAFILE *terra;
> >
> > int main (int c, char **v)
> > {
> >         terra = load_datafile("terra.dat");
> >         char *str;
> > }
> >
> 
>     [but this one did work for Paul]
> 
> >
> >DATAFILE *terra;
> >
> > int main (int c, char **v)
> > {
> >         char *str;
> >         terra = load_datafile("terra.dat");
> > }
> >
>     Maybe you've found another difference between C and C++.  In C,
>     variables need to be declared at the beginning of a function;
>     with C++, this isn't the case.  Did you compile these as C 
>     programs when you really meant to compile them as C++ programs?
>     What error messages did you receive? 
>   
> 
> 
> >        ...IT WORKS?!?!?!  I can live with writing it this way, but I want to 
> >know why the compiler pukes when I write it the other way.  Can any help me 
> >here?  I'd appreciate it!
> 
> [daydreaming]
> 
>     (I wish comp.lang.asm.x86 would be liberated...  I miss it.)
> 
> 
> 
> 
> -- 
>   beppu AT uci DOT edu .............................................................
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019