cfor-loopwarnings

C Warning: Statement with no effect


When trying to compile my program with

gcc -pedantic -Wall -ansi

I get the warning:

warning: statement with no effect

Referring to this line:

for(currentDirection; currentDirection <= endDirection; currentDirection++)

How can I fix this?


Solution

  • currentDirection; does nothing.

    Replace your line with

    for(; currentDirection <= endDirection; currentDirection++)
    

    Or, in case you just forgot to initialize the variable:

    for(currentDirection = 0; currentDirection <= endDirection; currentDirection++)