I get this error:
C0358: 'SEL(x, myEnum.green, myEnum.red)' is not a valid value for strict ENUM type 'myEnum'
When I remove the 'strict' attribute, the code compiles normally.
Any ideas? Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
NOTICE!
As of CODESYS V3.5 SP7, each enumeration that you add to a project receives the 'strict' attribute automatically in the line above the TYPE declaration. For compiler versions >=3.5.7.0 , this causes compile errors in the following cases:
Arithmetic operation with variables of the enumeration type
Assignment of a constant value to a variable of the enumeration type, in which the constant does not correspond to an enumeration value
Assignment of a non-constant value to a variable of the enumeration type, in which the non-constant has another data type than the enumeration type
The attribute can also be added explicitly or removed.
Syntax: {attribute 'strict'}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi everybody,
I declare the following enumeration:
Does anybode know the exact function of the Strict attribute?
And why does this code not compile:
I get this error:
C0358: 'SEL(x, myEnum.green, myEnum.red)' is not a valid value for strict ENUM type 'myEnum'
When I remove the 'strict' attribute, the code compiles normally.
Any ideas? Thanks!
You could try using the instance name
Bump
Was does {attribute 'strict'} do and can it be used outisde enums?
See the CODESYS Help:
NOTICE!
As of CODESYS V3.5 SP7, each enumeration that you add to a project receives the 'strict' attribute automatically in the line above the TYPE declaration. For compiler versions >=3.5.7.0 , this causes compile errors in the following cases:
Arithmetic operation with variables of the enumeration type
Assignment of a constant value to a variable of the enumeration type, in which the constant does not correspond to an enumeration value
Assignment of a non-constant value to a variable of the enumeration type, in which the non-constant has another data type than the enumeration type
The attribute can also be added explicitly or removed.
Syntax: {attribute 'strict'}