What does the extern keyword mean?

后端 未结 3 1798
梦谈多话
梦谈多话 2020-12-07 21:56

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

extern void DoFoo ...
3条回答
  •  忘掉有多难
    2020-12-07 22:50

    The extern keyword declares a variable or function and specifies that it has external linkage (its name is visible from files other than the one in which it's defined). When modifying a variable, extern specifies that the variable has static duration (it is allocated when the program begins and deallocated when the program ends). The variable or function may be defined in another source file, or later in the same file. Declarations of variables and functions at file scope are external by default.

    You can find a more complete description here.

提交回复
热议问题