4

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?

1
  • 3
    Yes, they are the same. Commented Sep 10, 2014 at 8:02

2 Answers 2

10

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"

Sign up to request clarification or add additional context in comments.

1 Comment

The reference from the specification is really useful! Thanks.
2

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

1 Comment

use any one signature.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.