I am trying to write a function that accepts an array as a parameter. However, the C compiler (lcc) is issuing a warning (i.e. my file still compiles) that “.\tetris.c:179: warning: declaration of `clear_array’ does not match previous declaration at .\tetris.c:172”.
Here is the portion of my code involving the function and a call to that function that’s raising the warning:
void remove_filled_rows ()
{
int row;
for (row = 0; row < NROWS; row++) {
// [snip]
if (col == NCOLS) {
clear_array (cells[row]); // line 172
}
}
}
/* Helper method that clears a row */
void clear_array (lc4uint row_array[]) { // line 179
int col;
for (col = 0; col < NCOLS; col++) {
row_array[col] = 0;
}
}
My array is declared as follows:
lc4uint cells[NROWS][NCOLS];
where NROWS and NCOLS are integer constants, and lc4uint is simply a typedef to unsigned int.
The declaration has to come before the access. Either move
clear_arrayto before you call it or add a prototype for theclear_arrayfunction prior to the call. You should have gotten an error/warning about this on any decent compiler.The give away — line 172 wasn’t supposed to be the declaration, line 179 was. But the error said 172 was the declaration.