The attribute 'const_replaced'
has the effect that the constant is replaced in the code, independently of the setting
of the “Replace constants” compiler option. The attribute has an effect for variables of scalar types only,
but not for compound types like arrays and structures.
You insert the pragma {attribute 'const_non_replaced'}
accordingly in order to explicitly deactivate the “Replace constants” compiler option. This has the effect, for example in the symbol configuration, that
the constant is available and can be exported despite the compiler option.
The “Replace constants” option in the “Compile Options” category of the “Project Settings” dialog is preset for the entire project, because replacing constants generally leads to faster code and less memory usage.
Syntax:
{attribute 'const_replaced'}
{attribute 'const_non_replaced'}
Insert location: Line above the declaration line of the global variables.
Example
The constants iTestCon
and xTestCon
are available in the symbol configuration because the “Replace constants” option deactivated.
{attribute 'qualified_only'} VAR_GLOBAL CONSTANT {attribute 'const_non_replaced'} iTestCon : INT := 12; {attribute 'const_non_replaced'} xTestCon : BOOL := TRUE; rTestCon : REAL := 1.5; END_VAR VAR_GLOBAL iTestVar : INT := 12; xTestVar : BOOL := TRUE; END_VAR