I want to have a static function which I declare in my .c file before defining it:
//file a.c version 1
static int foo();
...
static int foo()
{
...
}
However, it seems that I can leave the static
keyword out of the function definition and I get no compiler warnings... e.g.
//file a.c version 2
static int foo();
...
int foo()
{
...
}
Am I correct in assuming these two forms are exactly the same?
If so, why is this discrepancy allowed and which form should I use?
Yes 7.1.1/6
A name declared in a namespace scope without a storage-class-specifier has external linkage unless it has internal linkage because of a previous declaration and provided it is not declared
const
.
See also the examples of 7.1.1/7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With