Functions Are Extern by Default

Unless explicitly declared static, an ordinary function is implicitly declared extern in C and C++. For example:

 extern void func(int i); // extern is redundant

However, sometimes the extern qualifier is added to a function declaration to document the fact that it has external linkage and can be called from any module, or source file, for example:

 // from extern size_t strlen(const char * s); 

Do not confuse plain extern with extern “C”?the latter has a special meaning, i.e., the identifier has C linkage rather than C++ linkage.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: