Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dxcarnadi on June 14, 2016, 10:24:05 am

Title: C11 .. C89 .. ?
Post by: dxcarnadi on June 14, 2016, 10:24:05 am

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.
Title: Re: C11 .. C89 .. ?
Post by: BlueHazzard on June 14, 2016, 11:40:35 am
The error is pretty clear: "initial decelerations are only allowed in C99 and onward"

so in your code you have something like this:
for(int i = 0; i < 3;++i)

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:
int i = 0;
for(i= 0;i< 3;++i)

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