G
Guest
Let's say I have two files, myfile.h and myfile.c:
myfile.h:
int myfunction(int x);
myfile.c:
#include "myfile.h"
static int myfunction(char *x)
{
return 0;
}
Does this conform to the C standard? With GCC 4, this generates an
error, because the definitions of myfunction() conflict. I have a
colleague who says this compiles in GCC 3, because the static version
of myfunction() overrides the non-static prototype from the header
file. I believe that GCC 3 is just ignoring the problem, and that it's
technically a bug, but I can't find any documentation that specifically
says that static and non-static declarations of the same function have
to have the same parameters and return type.
myfile.h:
int myfunction(int x);
myfile.c:
#include "myfile.h"
static int myfunction(char *x)
{
return 0;
}
Does this conform to the C standard? With GCC 4, this generates an
error, because the definitions of myfunction() conflict. I have a
colleague who says this compiles in GCC 3, because the static version
of myfunction() overrides the non-static prototype from the header
file. I believe that GCC 3 is just ignoring the problem, and that it's
technically a bug, but I can't find any documentation that specifically
says that static and non-static declarations of the same function have
to have the same parameters and return type.