C99 Question

P

Pacher R. Dragos

This question referes to mingw compiler, a port of gcc for win32.

When I tryed yesterday to compile this code:

int test(void);

int main()
{
return 0;
}

int test()
{
for( int i = 0 ; i < 5 ; i++ );
return 0;
}

i got the following error: "something about C99 standard"
then I changet the code like that:
int i = 0;
for( i, ..)

and the error was gone.

It was strange. When I tryed to reproduce it with the latest compiler
from mingw I couldn't do it, so I'm asking if that was a bug or just a
misconfiguration.

In my large projects this is not happening. Maybe I should post it to
mingw newsgroup but it referes the C99 standard.

If anyone has encountered this kind of 'strange error' please let me
know.
 
S

Sriram Rajagopalan

Hi,

I assume the error you got was:
"error: `for' loop initial declaration used outside C99 mode"

You do not seem to have enabled the C99 mode here. Hence the error.

Enable the C99 mode, by using the compiler option "-std=c99".

Hope that helps.

Regards,
Sriram.
 
P

Pacher R. Dragos

Sriram said:
Enable the C99 mode, by using the compiler option "-std=c99".

Hope that helps.

Regards,
Sriram.

Yes. That was the problem, and in my projects it didn't happened
because they had that compiler command. This can be reproduced only
outside the projects.
In individual files without that command, I discovered after some
digging.
Thanks for the answer.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top