-2

I was wondering if there is any difference if skip extern storage class specifier while declaring a function? Specifically, is there any difference between following two?

void foo ();   

and

extern void foo();
Yu Hao
  • 119,891
  • 44
  • 235
  • 294
username_4567
  • 4,737
  • 12
  • 56
  • 92
  • Note that neither declaration is a prototype (in C). Both declare a function that takes an indeterminate (but fixed) list of arguments, possibly including zero arguments. It is not a 'variable length argument list' (varargs) function, though โ€” it is not like `printf()` et al. The story is different in C++; there the function is declared to take no parameters. โ€“ Jonathan Leffler Jul 14 '15 at 07:25
  • 1
    There's absolutely no point and no reason for using `extern` on function declarations. This is some archaic legacy habit, which has absolutely no value today. โ€“ AnT stands with Russia Jul 14 '15 at 07:39

1 Answers1

2

is there any difference between following two?

Basically, no.

Each function declaration, is extern by default, (i.e., in absence of any specific storage-class specifier).

Quoting C11, chapter ยง6.2.2, Linkages of identifiers

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