P4036¶
- Code
P4036
- Message
AT-located variable in a plain VAR block requires –allow-mixed-located-var-declarations flag
This error occurs when an AT-located variable (complete address like
AT %IX0.0, or incomplete/wildcard address like AT %I*) is declared
inside an otherwise plain VAR/VAR_INPUT/VAR_OUTPUT block,
without the --allow-mixed-located-var-declarations compiler flag. The
IEC 61131-3 standard requires located variables to be declared in their
own dedicated block, separate from ordinary symbolic variables. Mixing
them in one block is a vendor extension.
A block containing only located variables is unaffected by this error — that is standard syntax and always allowed.
Example¶
The following code will generate error P4036:
FUNCTION_BLOCK FB_Example
VAR
tempSensor AT%I*: INT;
fbComm : BOOL;
END_VAR
END_FUNCTION_BLOCK
To fix this error, either move the located variable into its own block:
FUNCTION_BLOCK FB_Example
VAR
tempSensor AT%I*: INT;
END_VAR
VAR
fbComm : BOOL;
END_VAR
END_FUNCTION_BLOCK
Or enable the vendor extension:
Pass the --allow-mixed-located-var-declarations flag to enable it, or select a dialect that includes it. See
Enabling Dialects and Features for the dialects and flags
reference.
Think IronPLC is wrong about this?
If you believe this diagnostic is incorrect, open an issue on GitHub with a small sample that demonstrates the problem.