I know about the static
keyword in C before a function declaration to only allow the file it is declared at to use the function (the compilation unit, to be more precise). I've done some research and I have found already answered questions regarding including them in headers, and what it does in detail, but I have one that I think is missing:
Does the static
keyword add anything to a program, when there's no other declaration of a function but the one followed by its definition ?
e.g. :
main.c
#include "foo.h"
int main () {
foo();
return 0;
}
foo.c
void foo2() {
return ;
}
void foo() {
return foo2();
}
foo.h
void foo();
What would be the difference if foo2()
was declared as static void
?