Compiler: Default compiler
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\forloop.c" -o "C:\forloop.exe" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib"
C:/forloop.c: In function main':
C:/forloop.c:3: error:for' loop initial declaration used outside C99 mode
Execution terminated
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2006-08-12
In either:
Tools|Compiler options|Compiler|Add the following commands when calling the compiler.
or
Project|Project options|Parameters|Compiler
The first is applied to all new projects and builds, the second to a specific project. You can modify teh project templates if you want it to apply to some project types and not others.
Given the age of this thread, it might have been a good idea to start a new one (possibly referencing this one with a link).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"No problem, pass the following command to the compiler to activate the C99 mode:
-std=c99 "
Where do I type that in?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-02-26
Compile the same code as C++ and it should be OK.
Since the C++ compiler has stronger error checking, it is probably good to use it even for C code. There are some minor semantic differences, but that should not be a problem.
Also even if you do not want to do OO, you get somethings for free, like a boolean data type, references, and function overloading (these things carry little or no overhead compared with C code).
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, thanks for your answers. One more question: since C99 is no longer a subset of C++, meaning that there are some C99 features that are not part of C++ (like variable length arrays, for example) - how does MinGW handle this situation? Can I use C99 features (provided that MinGW provides them) and C++ features in the same C++ sources? Thanks, OP
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-02-26
Most compiler vendors are concentrating on C++ compliance. C99 is not fully supported in many compilers. For teh sake of portability of code I'd use either C89 or ISO C++.
Beware however, that use of such extensions is at the expense of portability. On the other hand GCC is available for Mac, Linux, Windows, and Embedded systems, so this may not be an issue.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, what's wrong with the program below? I believe MinGW actually does support most parts of C99, doesn't it? Thanks for any hint, OP
int main(void)
{
for(int i=0; i<=10; i++) // ERROR
;
return 0;
}
Compiler: Default compiler
Compiler: Default compiler
Executing gcc.exe...
gcc.exe "C:\forloop.c" -o "C:\forloop.exe" -I"C:\DEV-CPP\include" -L"C:\DEV-CPP\lib"
C:/forloop.c: In function
main': C:/forloop.c:3: error:
for' loop initial declaration used outside C99 modeExecution terminated
In either:
Tools|Compiler options|Compiler|Add the following commands when calling the compiler.
or
Project|Project options|Parameters|Compiler
The first is applied to all new projects and builds, the second to a specific project. You can modify teh project templates if you want it to apply to some project types and not others.
Given the age of this thread, it might have been a good idea to start a new one (possibly referencing this one with a link).
Clifford
No problem, pass the following command to the compiler to activate the C99 mode:
-std=c99
"No problem, pass the following command to the compiler to activate the C99 mode:
-std=c99 "
Where do I type that in?
Compile the same code as C++ and it should be OK.
Since the C++ compiler has stronger error checking, it is probably good to use it even for C code. There are some minor semantic differences, but that should not be a problem.
Also even if you do not want to do OO, you get somethings for free, like a boolean data type, references, and function overloading (these things carry little or no overhead compared with C code).
Clifford
Ah, thanks for your answers. One more question: since C99 is no longer a subset of C++, meaning that there are some C99 features that are not part of C++ (like variable length arrays, for example) - how does MinGW handle this situation? Can I use C99 features (provided that MinGW provides them) and C++ features in the same C++ sources? Thanks, OP
Most compiler vendors are concentrating on C++ compliance. C99 is not fully supported in many compilers. For teh sake of portability of code I'd use either C89 or ISO C++.
Fron the GCC documentation: "Some features that are in ISO C99 but not C89 or C++ are also, as extensions, accepted by GCC in C89 mode and in C++.". Refer to http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/C-Extensions.html#C-Extensions and http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/C_002b_002b-Extensions.html#C_002b_002b-Extensions for more details. You may want to start here to get teh full picture: http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Standards.html#Standards
All the documenation is available here: http://gcc.gnu.org/onlinedocs/
I guess what I am saying is RTFM! ;-)
Beware however, that use of such extensions is at the expense of portability. On the other hand GCC is available for Mac, Linux, Windows, and Embedded systems, so this may not be an issue.
Clifford
See also:
http://www.cran.org.uk/bruce/blog/index.php?p=27
("Microsoft vs C99")