Jump to content
  • Advertisement
Sign in to follow this  
shishio

c99 mode

This topic is 4814 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have a question: what is c99 mode? I was using the Dev C++ compiler and got this error message: 'for' loop initial declaration used outside C99 mode Thanks again.......

Share this post


Link to post
Share on other sites
Advertisement
I believe it is complaining because

// you aren't supposed to do this anymore:
for(int x = 0; x < 35; x++)
{
// do something
}
for(x = 0; x < 35; x++)
{
// do something else
}

// instead, do this:
int x; // define it here because otherwise it is undefined when you reach the second loop
for(x = 0; x < 35; x++)
{
// do something
}
for(x = 0; x < 35; x++)
{
// do something else
}



Edit: Removed my speculation about C99 since people who knew the answer said it was wrong. I also altered the code slightly based on a quick test which seems to indicate that the compiler only complains if you try to use a variable declared in the for() line outside of that loop.

[Edited by - mumpo on June 16, 2005 7:03:40 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by shishio
what is c99 mode?


C99 is the latest C standard (not C++), Dev-C++ uses mingw compiler a GCC compiler which supports some of the C99 standard aswell as the C++ standard but also supports its own language extensions, when in "C99 mode" it means strict conformance to C99 standard no GCC extensions allowed.

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
I believe it is complaining because

// you aren't supposed to do this anymore:
for(int x = 0; x < 35; x++)
{
// do something
}
// instead, do this:
int x;
for(x = 0; x < 35; x++)
{
// do something
}

C99 mode most likely refers to a mode in which the compiler is using the 1999 C++ standard, which allowed you to do it the first way (though I believe it still gave you a warning). The current version of the C++ standard appears to be 2005, which apparently has upgraded that warning to an error.


Wow you have this so backwards & wrong [lol]

1. There is no C++ 99 standard, C99 refers to the latest C standard not C++, they are separate and C++ is not a proper super-set of C anymore (as of this moment).

2. There is no C++ 2005 standard, its sounds like your just talking about VC++ 8.0

3. What you said about for loops is backwards, both are valid in anycase in C++ & C99.

[Edited by - snk_kid on June 15, 2005 8:11:38 PM]

Share this post


Link to post
Share on other sites
After further investigation your under C89 mode [rolleyes] consider:


int main() {

for(int x = 0; x < 4; ++x)
;
}


GCC:


$ gcc -std=c89 foo.c -c
foo.c: In function `main':
foo.c:3: error: 'for' loop initial declaration used outside C99 mode


Looks fimillar wright [wink].

Share this post


Link to post
Share on other sites
Thanks for the background on c99 mode... I read somewhere that c99 isn't supported by Microsoft... I found this online which gave me some info for anyone else interested:

http://www.cran.org.uk/bruce/blog/index.php?p=27

I actually figured out myself to change the for loop as suggested by mumpo and that made the compiler error go away, but I wanted to know what c99 mode referred to...

Share this post


Link to post
Share on other sites
Quote:
Original post by shishio
Thanks for the background on c99 mode... I read somewhere that c99 isn't supported by Microsoft... I found this online which gave me some info for anyone else


Yeah it seems they sell their compiler mainly as a C++ compiler not really C so its going to try and conform with the C++ standard more than C (although there are talks with both standards to combine and stuff) plus now MS have introduced a new standardized language C++/CLI which its latest C++ compiler supports too i think they are going to focus on that more for the time being.


Quote:
Original post by shishio
I actually figured out myself to change the for loop as suggested by mumpo and that made the compiler error go away, but I wanted to know what c99 mode referred to...



if your using C++ or C99 (and i think any with GCC extensions on) both forms are valid.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!