User forums > Using Code::Blocks
Problem compiling "for loop" with codeblocks compiler.
deva:
Hi friends,
I am using GNU GCC Compiler
OS: win7 32bit
/* Program 4.2 Drawing a box */
#include <stdio.h>
int main(void)
{
printf("\n**************"); /* Draw the top of the box */
for(int count = 1 ; count <= 8 ; ++count)
printf("\n* *"); /* Draw the sides of the box */
printf("\n**************\n"); /* Draw the bottom of the box */
return 0;
}
when i try to compile the code i got fallowing error.
C\48.c|6|error: 'for' loop initial declarations are only allowed in C99 mode|
C\48.c|6|note: use option -std=c99 or -std=gnu99 to compile your code|
If anybody know how to change it to c99mode please help me.
Thanks & Regards,
Deva
Hi, I changed to -std=c99 mode is this way correct ?
Please see picture
Untitled.png:
Hi friends,
My problem solved. many of them adviced me to change settings to -std=c99 But its not worked because my compiler is GNU GCC Compiler.
Here is see how the problem is fixed.
In the Compiler and Debugger settings. Compiler settings tab - Other Options. I added there -std=gnu99
So Problem solved.
Friends thanks very much for your advices & time.
Thanks & Regards,
Deva
zabzonk:
Go to the Project menu, then Build Options..., then Compiler Settings|Other options tab, then enter -std=c99 and hit OK.
deva:
Hi,
Thanks for your reply. In the projecet menu build options is disable I mean its not highlited. How can we enable it?.
zabzonk:
CB is project based. Before you write any code, create a project from Create New Project on the CB startup screen, and select Console Application - the Build Options will be enabled after you create a project.
oBFusCATed:
--- Quote from: Neil Butterworth on November 10, 2011, 09:31:30 am ---CB is project based. Before you write any code, create a project from Create New Project on the CB startup screen, and select Console Application - the Build Options will be enabled after you create a project.
--- End quote ---
Wrong, C::B supports single file compilation, too.
For the compilation it uses the default compiler,
so you can set the option in the settings,
but this is not a good practice in the long run.
No, debugging is supported in single file mode.
Navigation
[0] Message Index
[#] Next page
Go to full version