User forums > Using Code::Blocks

C11 .. C89 .. ?

(1/1)

dxcarnadi:
Hello

I'm learning (by myself) C with a book from Ivor Horton "Beginning C".
As IDE I use Code::Block in Windows-10.

I tried to compile/build an example from that book .. got the error messages.
Please see the attachment.
Why .. the errors?
What should I do?
Thank you for your help.

BlueHazzard:
The error is pretty clear: "initial decelerations are only allowed in C99 and onward"

so in your code you have something like this:

--- Code: ---for(int i = 0; i < 3;++i)
--- End code ---

prior to the C99 standard it was not allowed do declare your variable in the for loop header.
To fix this you can use the following code:

--- Code: ---int i = 0;
for(i= 0;i< 3;++i)
--- End code ---

or you compile with c99 enabled:
Project->Build options
make sure you have selected the top most entry in the tree control on the left
Compiler settings->Compiler flags-> Make a tick at "Have gcc follow the 1999 ISO C lang......" -> OK
rebuild your project by
Build->Rebuild

greetings

Navigation

[0] Message Index

Go to full version