Mail Archives: djgpp/1996/06/23/01:47:31
>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 -