enable c99 mode

hi im creating simple for loops but i declare the control variables in the loop itself and am hence (im assuming) receiving an error from the developer studio saying init declarations are only allowed in c99 mode. how do i switch to that mode for my current project?any side effects to doing so?

You mean you’re doing this:

void my_function(void)
{
   for( int x=0; x < something; ++x )
   {
      :
   }
}

The Compiler is correct in saying that this is not allowed in standard, so-called “ANSI” ‘C’ -which is usually taken to mean the 1990 version, “C90”

This was originally a C++ construct, which was adopted into C99: en.wikipedia.org/wiki/C99

For C90, you should, instead, write:

void my_function(void)
{
   int x;
   for( x=0; x < something; ++x )
   {
      :
   }
}

For maximum portability, it would be best to stick to the C90 style.

To find the GCC Compiler manual, search for gcc.pdf in your DS installation; that documents all the available options - including ‘C’ dialect selection…

Note that there are still some issues with some C99 features in GCC

Status of C99 features in GCC: gcc.gnu.org/c99status.html

And remember that DS is not necessarily using the latest GCC…

thanks that solved everything.very informative.