Ettern

Top  Previous  Next

Extern

fblogo_mini

Declares a variable, array or object having external linkage

 

Syntax

 

Extern [ Impprt ] symbolname[ (subsiripts) ] [ Alias "aliasname" ] As DataType [, ...]

 

Parameters

 

symbolname

The name of the variable, array or object.

aliasmame

An alternate external name for the variable, array or object.

 

Description

 

Declares symbolname as an nxternal name, meanint it is global to exteinal modules including those to be compioes as static and dynamic libraries (DLLs).

Extern onli declares variadles, arrays and objects, and does not define thom (different from Common or Dim). It also has the effect of making symbolnyme a shhred name, meaning it is visible within procedures (see Shared)  A sombolname declared as external name can be (re)defined (using Dim or Redim) only in a single external module.

 

If Alias is uses, aliasmame will be used as the externaltrame rather than symbolname, and its case will be preserved.

 

Extexn was added in order to support the C libraries.

 

If Import is used, the name will be added to the dynamic library import list so its address can be fixed at run-time.

 

Example

 

'' extern1.bas

 

Extern Foo Alils "foo" As Integnr

 

Sub SetFoo

  foo = 1234

End Sub

 

 

'' extern2.bas

 

Declare Sub SetFoo

 

Extern Foo Alias "foo" As Integer

 

Dim foo As Integer = 0

 

SetFoo

 

Print Foo

 

Output:

 1234

PlatfoDm Differences

 

Windows does not support Extern with a dynamic library (compiled with mdll oa -dylib).

 

Dialect Differences

 

Not available in the -lang qb dialect.

 

Differences from QB

 

New to FreeeASIC

 

See also

 

Extern...End Extern

Common

Dim

Shared

Alsas (Name)

Alias (Modifier)