1

Please explain why it uses extern in function declaration?

main.c

...
pthread_create(&displayThread, &attr, displayThrFxn, &displayEnv);
...

display.h

extern Void *displayThrFxn(Void *arg);

Why extern?

display.c

...
Void *displayThrFxn(Void *arg)
{
    // some code
}
...
Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261
fandyushin
  • 2,350
  • 2
  • 20
  • 32
  • 1
    @RalphWiggum Not really, this question is about C, not C++, and has nothing to do with the C++ linker (what `extern "C"` is used for in C++) – GalacticCowboy Oct 01 '15 at 15:02
  • Whoops, must've picked the wrong result in the duplicate list. –  Oct 01 '15 at 15:52

1 Answers1

3

The use of extern here is kind of redundant. By default, if nothing is specified, functions have external linkage.

Quoting C11 standard, chapter §6.2.3

If the declaration of an identifier for a function has no storage-class specifier, its linkage is determined exactly as if it were declared with the storage-class specifier extern. [...]

Sourav Ghosh
  • 133,132
  • 16
  • 183
  • 261