What is the difference between the following declarations in C?
static int foo(){}
int static foo(){}
As I understand the first format is used and subscribed in text books while the second nonetheless seems to work as well. Are the declarations equivalent?
They are the same but the first form is preferred:
(C99, 6.11.5p1) "The placement of a storage-class specifier other than at the beginning of the declaration specifiers in a declaration is an obsolescent feature"
When you run the functions you will get an error like " static declaration of foo follows non-static declaration ".
It is not correct in C to use static in this way because static functions are visible in only the file you created
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