Attention
IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include arrays and structures. Try it out in the IronPLC Playground.
P4029¶
- Code
P4029
- Message
Constant reference in type parameter requires –allow-constant-type-params flag
This error occurs when a constant name is used in place of an integer literal in a type parameter (such as a STRING length or array bound) without the --allow-constant-type-params compiler flag. In the IEC 61131-3 standard, type parameters require integer literals. Using constant references is a vendor extension.
Example¶
The following code will generate error P4029:
VAR_GLOBAL CONSTANT
MAX_LEN : INT := 100;
END_VAR
FUNCTION_BLOCK MyFB
VAR_INPUT
name : STRING[MAX_LEN];
END_VAR
END_FUNCTION_BLOCK
To fix this error, either use an integer literal directly:
FUNCTION_BLOCK MyFB
VAR_INPUT
name : STRING[100];
END_VAR
END_FUNCTION_BLOCK
Or enable the vendor extension with the --allow-constant-type-params flag.