There's [almost] never any need to use the keyword extern
when declaring a function, either in C or in C++. In C and in C++ all functions have external linkage by default. The strange habit of declaring functions in header files with extern
probably has some historical roots, but it has been completely irrelevant for decades already.
There's one [obscure?] exception from the above in C, which is probably not directly related to what you are asking about: in C language (C99) if in some translation unit a function is defined as inline
and also declared as extern
(an explicit extern
is used) then the inline definition of that function also serves as an external definition. If no declarations with explicit extern
are present in the translation unit, then the inline definition is used as "internal" definition only.
P.S. There's such thing as extern "C"
in C++, but that is a completely different matter.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…