1

I just copied copy.c to whodunit.c.

Then I saved and tried to compile the program by running make whodunit. This resulted in the following error.

whodunit.c: 73:5 error: for loop initial declarations are only allowed in c99 mode

What have I done wrong?

2
  • 1
    Run update50 and try again. Do you still get the error?
    – Calculemus
    Jan 11, 2015 at 5:13
  • 1
    After update50, no more error noted. Thanks Calculemus~
    – Hang Man
    Jan 11, 2015 at 10:56

1 Answer 1

1

This problem was most likely caused by the original make compilation settings in the Appliance. A simple update50 command fixed it, as the poster noted in a comment to the original post.

The for loop syntax that we learn in CS50, an example of which is included below, is defined in the C99 standard for the C programming language.

for (int i = 0; i < 10; i++;);

The older C89 standard required the variable declaration int i; to be done outside the for loop, as below.

int i;
for (i = 0; i < 10; i++;)

The Clang compiler adheres to the old C89 standard by default, unless -C99 is specified as an option, and will emit an error if it encounters C99 syntax in a C file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .