Is it possible under VS 2008 C/C++ compiler, compiling the following code in/as a .c file ?

int f(int bounds)
{
   int sum = 0;
   for( int i = 0; i < bounds ; i++ )
   { .... } 
   return sum;
}

GCC seem to be ok with that C syntax, but it looks like VS'2008 is more expecting something like:

int f(int bounds)
{
   int sum = 0, i;
   for( i = 0; i < bounds ; i++ )
   { .... } 
   return sum;
}
有帮助吗?

解决方案

Is it possible under VS 2008 C/C++ compiler, compiling the following code in/as a .c file ?

No. This is a C99 feature and MSVC doesn't support C99. You must have to declare i before for loop.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top