Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the extern keyword mean?

What does the extern keyword mean? I've seen that in front of an function declaration like

extern void DoFoo ... 
like image 387
dontWatchMyProfile Avatar asked May 02 '10 15:05

dontWatchMyProfile


People also ask

What is an extern keyword?

“extern” keyword is used to extend the visibility of function or variable. By default the functions are visible throughout the program, there is no need to declare or define extern functions. It just increase the redundancy. Variables with “extern” keyword are only declared not defined.

What does the extern keyword mean in C?

extern "C" specifies that the function is defined elsewhere and uses the C-language calling convention. The extern "C" modifier may also be applied to multiple function declarations in a block. In a template declaration, extern specifies that the template has already been instantiated elsewhere.

What is extern used for?

Extern is a short name for external. used when a particular files need to access a variable from another file.


1 Answers

extern gives a name external linkage. This means that the object or function is accessible through this name from other translation units in the program. For functions, this is the default linkage in any case so its usage (in this context) is usually redundant.

like image 137
CB Bailey Avatar answered Sep 28 '22 18:09

CB Bailey