News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

C11 .. C89 .. ?

Started by dxcarnadi, June 14, 2016, 10:24:05 AM

Previous topic - Next topic

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:
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
Build->Rebuild

greetings