extern functions in header file
Eljay Love-Jensen
eljay@adobe.com
Fri Sep 10 10:40:00 GMT 2004
Hi Ming-Chia,
>Is there any difference between declaring functions with prefix "extern"
and without "extern" keyword in header files?
From a C++ vantage point...
Effectively (by and large), no there's no difference.
Philosophically, yes. Some consider (including myself) that supplying the
(optional) <code>extern</code> keyword is good practice because it is
self-documenting code.
Also, be aware that <code>extern "C"</code> has several important
(critical!) implications regarding C++ code.
Also, in some areas, <code>extern</code> is REQUIRED to distinguish
something that is "just a declaration" from being mistaken for a
"definition" (without having the <code>extern</code>). See Stroustrup's
C++ Programming Language (3rd or special edition) section 9.2.
I haven't done C work since 1990, so my comments may not be appropriate for
C "good style / best practices".
HTH,
--Eljay
More information about the Gcc-help
mailing list