Attribute linkalways

Overview

Use the pragma {attribute 'linkalways'} to mark a POU or a library POU for the compiler in a way so that they are always included into the compile information. During the build, objects with this option are compiled and become part of the application code. With a download, the POUs are downloaded to the controller. The POU can be valid for the project (if located in the POUs tree) or for the application (if located in the Devices tree).

The compiler option Link always has the same effect.

Syntax

{attribute 'linkalways'}

Insert the pragma in the fist line of the declaration part of a POU or a library POU.

When you use the symbol configuration editor, the marked POUs are used as a basis for the selectable variables for the symbol configuration.

Example

The global variable list MoreSymbols GVL is implemented making use of the attribute 'linkalways'. The variables declared are included in the application code, no matter whether they are accessed or not.

MoreSymbols GVL

{attribute 'linkalways'}
VAR_GLOBAL
        g_iAlpha: INT;
        g_iBravo: INT;
        g_iCharlie: INT;
END_VAR

As a result, the symbols of MoreSymbols GVL are available in the Symbol configuration.