delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/22/16:07:46

Message-ID: <01BB6054.A8EF6040@hf2rules.res.jhu.edu.res.jhu.edu>
From: "Michael A. Phelps" <morphine AT cs DOT jhu DOT edu>
To: "djgpp AT delorie DOT com" <djgpp AT delorie DOT com>,
"'Robert Fremin'"
<robert DOT fremin AT mailbox DOT swipnet DOT se>
Subject: RE: Does DJGPP conform to ANSI-C standards with the for () ?
Date: Sat, 22 Jun 1996 16:05:37 -0400
MIME-Version: 1.0

----------
From: 	Robert Fremin[SMTP:robert DOT fremin AT mailbox DOT swipnet DOT se]
Sent: 	Saturday, June 22, 1996 12:13 PM
To: 	djgpp AT delorie DOT com
Subject: 	Does DJGPP conform to ANSI-C standards with the for () ?

I had great difficulties to compile this code (example):

void main()
{
	for (int i=0; i<100; i++);
}

All I got was errors, i not initialized it said.
I tried to move it out to...

void main()
{
	int i;
	for (i=0; i<100; i++);
}

....but all the same.

It only worked when I (at last) put the i globally.

int i;
void main()
{
	for (i=0; i<100; i++);
}

Interesting.  I tried the following code with DJGPP V2 and it worked:
	int	main()
	{
		int	i;
		
		for (i = 0; i < 100; i++);

		return 0;
	}

Also, when using C++, the following code worked, as expected:
	int	main()
	{
		for (int i = 0; i < 100; i++);

		return 0;
	}

What makes DJGPP unable to use local variables in for() and asm("") ?
Someone?
You can declare variables as static and use them in an asm() construct.

						--Michael Phelps
						  morphine AT cs DOT jhu DOT edu

- Raw text -


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