www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/23/01:47:31

Xref: news2.mv.net comp.os.msdos.djgpp:5277
From: nelson AT cs DOT uwp DOT edu (Jeremy Nelson)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Does DJGPP conform to ANSI-C standards with the for () ?
Date: 23 Jun 1996 02:49:37 GMT
Organization: University of Wisconsin - Parkside
Lines: 45
Message-ID: <4qibc1$434@news.inc.net>
References: <01BB6054 DOT A8EF6040 AT hf2rules DOT res DOT jhu DOT edu DOT res DOT jhu DOT edu>
NNTP-Posting-Host: 131.210.1.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>From: 	Robert Fremin[SMTP:robert DOT fremin AT mailbox DOT swipnet DOT se]
>
>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...


This is not valid C code for at least several reasons:

1) main must return int.  void is not acceptable.
2) main must take either void parameters or an int and a char **.
   an undefined param list is not acceptable.
3) 'int i' is not valid in the declaration portion of a for loop.
   this is valid c++ code, but not valid c.

The compiler is well within its rights to reject your program
for any of these three reasons, but gcc only rejects because of #3:

test.c: In function `main':
test.c:3: syntax error before `int'
test.c:3: `i' undeclared (first use this function)
test.c:3: (Each undeclared identifier is reported only once
test.c:3: for each function it appears in.)
test.c:3: syntax error before `)'


>void main()
>{
>	int i;
>	for (i=0; i<100; i++);
>}
>
>....but all the same.

Odd -- it compiled for me.  Could you elaborate *specifically* as to the
error messages you got?


-jfn

- Raw text -


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