may refer to variables, objects or procedures defined within their module or in another module. Having external linkage means that a name is outwardly visible to other modules, and all modules that use that same external name all refer to the same variable, object or procedure. Thus, only one module may define an external name (the compiler will complain about a duplicated definition if it finds an additional definition of a name with external linkage).
Variable and object names declared at module-scope are declared to have external linkage with
Extern or
Common.
Extern declares the variable having external linkage, but does not define it. This external declaration must come before any definition of the same name (a declaration without
Extern specifies internal linkage, and currently, any further external declarations of that name signify a duplicated definition). Variable and object names with external linkage declared using
Extern are always in the shared scope, and so can be referred to within procedure bodies.
Common declares the variable having external linkage as well as defining the variable. But, it is different from
Extern in that the
Common definition of the variable may appear in more than one module. When used with arrays, only variable-length arrays without subscripts may be declared, and the array must be sized at run-time using
Dim or
ReDim before it can be used. Variable and object names with external linkage declared using
Common are only in the shared scope if the
Shared scope specifier is also given. Shared variables can be referred to within procedure bodies.
When both
Extern and
Common are both used to declare and define a variable, the effect is that the meaning of
Common statement is altered to behave as though it were a
Dim declaration. So it is generally, not recommended to mix
Extern and
Common on the same variable in the same module. However, variables may be declared and defined with
Common in one module and then referenced with
Extern in another module without confusion.
Procedure names are declared to have external linkage by default. Declarations using
Public explicitly specify external linkage.
Currently, names declared at local-scope cannot have external linkage.