cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/02/14/15:30:32

Message-ID: <36C7320E.FB4111F9@lycosmail.com>
Date: Sun, 14 Feb 1999 15:29:02 -0500
From: Adam Schrotenboer <ajschrotenboer AT lycosmail DOT com>
X-Mailer: Mozilla 4.5 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Newbie Question (variable dec.)
References: <36c399d2 DOT 18754602 AT news DOT okstate DOT edu>
Reply-To: djgpp AT delorie DOT com

I don't know why this happens, but I do have to say that I do that kind
of thing often (in C++ mind you). Q, do you have optimizations on?? That
_might_ to it.
(Certain loop optimizations are somewhat untested, such as
loop-unrolling)

Also, in this case (though w/ gcc it may be somewhat irrelevant) you
could write it as:
for(int x=0;x<=10;x++) printf("%i\n,x).

This makes x local to the loop, and unusable(out of scope) anywhere
else.

Carl Marg wrote:

> I'm using DJGPP, and I've noticed that it will not allow me to
> declare variable in the middle of code, i.e
>
> int x,y;
> for (x=0;x<=10;x++) printf("%i\n",x);
> for (y=0;y<=10;y++) printf("%i\n",y);
>
> the code above would work, while below it would give me a parse error
>
> int x;
> for (x=0;x<=10;x++) printf("%i\n",x);
> int y;
> for (y=0;y<=10;y++) printf("%i\n",y);
>
> what I'm wondering is this just a part of standard C,
> is there some option that will change this?
>
> Carl Marg

- Raw text -


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