0

When I run breakout these error happen:

breakout.c:141:9: error: unused variable 'row_space'
      [-Werror,-Wunused-variable]
    int row_space = 20;

and

breakout.c:29:11: error: implicit declaration of function
      'time' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
    srand(time(NULL));

Maybe I am just looking way to hard to find these errors

CODE

Code removed per Honor Code

1
  • Please make sure to mark an answer as accepted if it solved your issue. :) – Wiktor Czajkowski Jul 28 '15 at 9:21
2
  1. First error is caused by, as the message says, declaration of a variable that's never used. If you're wondering how that's an error, I suggest you to watch this CS50 short short on how clang and in turn make work: Make, Clang.

    In short (no pun intended), since CS50 staff decided you are supposed to run programs with absolutely no errors whatsoever, they made make (which isn't compiler itself) invoke clang (that's the one!) with -Werror and -Wall options. It turns on all warnings (like the unused variable one) and makes them errors, thus stopping your program from being compiled.

    Edit: Seems like I got carried on and haven't explained enough what is actually causing an error.

    You declared variable, row_space, in line 141 of your program, with value 20. Your mistake, and thus error, is that you're not using it throughout your program, i.e. you're changing its value, use any functions with it as argument, etc. Its existence in your code is bassically pointless and compiler is pointing that out.

  2. You used time() function, which isn't in any of the libraries you supplied. Try to use man command or reference page to find the correct one.

4
  • Virzen, thanks for the help. But when I do Clang -Wall it says error: no input files – Ani Jul 29 '15 at 13:59
  • Well, my point wasn't to make you use clang directly, but to draw your attention to the fact, that you declared variable row_space and never used it. – Wiktor Czajkowski Jul 29 '15 at 20:47
  • I have edited my answer with more details. – Wiktor Czajkowski Jul 29 '15 at 20:56
  • Thanks! I have removed a useless variable. But that leads to a MAJOR problem. Link here: cs50.stackexchange.com/questions/10866/… – Ani Jul 30 '15 at 13:39

You must log in to answer this question.

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