Re: extern functions in header file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux