## ALP Programming Guide and Reference

[prev][next][parent][TOC]

### COMM (Declare Communal Variable)

Declares an uninitialized common or communal variable that is allocated by the linker.

Syntax

    COMM   [ Language - Name ]   [ Distance ]   Name [ [ Count ] ] : TypeName [ : Size ]   [ ,   . . . ]

Remarks

The arguments to the COMM directive are as follows:

Language-Name Optional parameter that determines how Name is spelled when written to the object file. Used when interfacing with routines written in high-level languages. If not specified, the language defaults to the value set by .MODEL or OPTION LANGUAGE.

Distance One of NEAR or FAR; determines the distance of allocated variable. If not specified, the current memory model determines the distance. The default is NEAR if no memory model is active.

Name The name of the variable to be allocated by the linker. This field is required.

[Count] Optional; if specified, this parameter must be surrounded by square brackets. The Count parameter can be thought of as a major (row) array dimension. It defaults to 1 if not specified.

TypeName Required parameter that specifies the type of the variable being allocated. It must be a single keyword or identifier that specifies a Distance-TypeName, Scalar-TypeName, or UserDefined-TypeName.

Size Size is an optional parameter that can be thought of as a minor ( column) array dimension. It defaults to 1 if not specified.

Communal variables are allocated by the linker. When the linker combines object modules together, all instances of an identically-named communal variable are merged into a single instance (union), and are uninitialized.

The allocated size of a communal variable is the largest size requested by all encountered references.

The allocation order with respect to the addresses of other global symbols is undefined; an application must not depend on the address of a communal variable being less than or greater than that of another global symbol.

A variable allocated with the COMM directive need not be declared in all referencing modules as communal; the linker matches all EXTERN/EXTRN references with that of the communal variable. Similarly, a variable allocated in one module with the PUBLIC directive may be declared in other modules as communal.

Since communal variables cannot be initialized and their address positions cannot be compared, use of the COMM directive is discouraged. The EXTERNDEF directive should be used instead.