Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
I am using static analysis which warn me about variable A being greater than 1024 bytes
Why is that a problem? And what should I do if I have big variables?
PROGRAM PLC_PRG
VAR CONSTANT
nr_of_motors:INT:=2;
END_VAR
VAR
GetState : ARRAY[1..nr_of_motors] OF CIA405.GET_STATE;
devState : ARRAY[1..nr_of_motors] OF CiA405.DEVICE_STATE;
enableDev: ARRAY[1..nr_of_motors] OF BOOL:=[nr_of_motors(FALSE)];
confirmDev: ARRAY[1..nr_of_motors] OF BOOL;
A: ARRAY [1..nr_of_motors] OF Motor;
initPRG:BOOL:=TRUE;
operational:ARRAY [1..nr_of_motors] OF BOOL;
i0:int;
END_VAR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
there is a justification in the help but I couldn't find any such coding guidelines in the first two google results. I suppose it is good to check your biggest variables, maybe you accidentally made a very large array that would cost processor time loading it into memory. Once checked, you can add the static analysis pragmas to ignore it in future. Or you could change the limit a bit higher.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like to understand what you mean by "that would cost processor time loading it into memory". Outside of arguments passed by value and assignments (which require the array to be copied, but probably are an atypical way to use an array), do you know of cases where a large array size causes sustained CPU load issues by itself, not related to explicit processing such as iterating over the array?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using static analysis which warn me about variable A being greater than 1024 bytes
Why is that a problem? And what should I do if I have big variables?
PROGRAM PLC_PRG
VAR CONSTANT
nr_of_motors:INT:=2;
END_VAR
VAR
GetState : ARRAY[1..nr_of_motors] OF CIA405.GET_STATE;
devState : ARRAY[1..nr_of_motors] OF CiA405.DEVICE_STATE;
enableDev: ARRAY[1..nr_of_motors] OF BOOL:=[nr_of_motors(FALSE)];
confirmDev: ARRAY[1..nr_of_motors] OF BOOL;
A: ARRAY [1..nr_of_motors] OF Motor;
initPRG:BOOL:=TRUE;
operational:ARRAY [1..nr_of_motors] OF BOOL;
i0:int;
END_VAR
there is a justification in the help but I couldn't find any such coding guidelines in the first two google results. I suppose it is good to check your biggest variables, maybe you accidentally made a very large array that would cost processor time loading it into memory. Once checked, you can add the static analysis pragmas to ignore it in future. Or you could change the limit a bit higher.
I would like to understand what you mean by "that would cost processor time loading it into memory". Outside of arguments passed by value and assignments (which require the array to be copied, but probably are an atypical way to use an array), do you know of cases where a large array size causes sustained CPU load issues by itself, not related to explicit processing such as iterating over the array?