Reputation: 1144
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?
Upvotes: 4
Views: 180
Reputation: 93
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
Upvotes: 2
Reputation: 145829
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"
Upvotes: 10