How to solve static declaration follows non-static declaration in GCC C code?
Try -Wno-traditional
.
But better, add declarations for your static functions:
static void foo (void);
// ... somewhere in code
foo ();
static void foo ()
{
// do sth
}
While gcc 3.2.3 was more forgiving of the issue, gcc 4.1.2 is highlighting a potentially serious issue for the linking of your program later. Rather then trying to suppress the error you should make the forward declaration match the function declaration.
If you intended for the function to be globally available (as per the forward declaration) then don't subsequently declare it as static. Likewise if it's indented to be locally scoped then make the forward declaration static to match.
From what the error message complains about, it sounds like you should rather try to fix the source code. The compiler complains about difference in declaration, similar to for instance
void foo(int i);
...
void foo(double d) {
...
}
and this is not valid C code, hence the compiler complains.
Maybe your problem is that there is no prototype available when the function is used the first time and the compiler implicitly creates one that will not be static. If so the solution is to add a prototype somewhere before it is first used.
I have had this issue in a case where the static
function was called before it was declared. Moving the function declaration to anywhere above the call solved my problem.