C

Asked • 05/10/19

Effects of the extern keyword on C functions?

In C, I did not notice any effect of the `extern` keyword used before function declaration.At first, I thought that when defining `extern int f();` in a single file **forces** you to implement it outside of the file's scope. However I found out that both: extern int f(); int f() {return 0;}and extern int f() {return 0;}compile just fine, with no warnings from gcc. I used `gcc -Wall -ansi`; it wouldn't even accept `//` comments.Are there any effects for using `extern` **before function definitions**? Or is it just an optional keyword with no side effects for functions.In the latter case I don't understand why did the standard designers chose to litter the grammar with superfluous keywords.**EDIT:** To clarify, I know there's usage for `extern` in variables, but I'm only asking about `extern` in **functions**.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.