P4020¶
- Code
P4020
- Message
Source does not contain a PROGRAM declaration
This error occurs when the compiler cannot find a PROGRAM declaration in the source. At least one PROGRAM is required to compile and run.
Example¶
The following code will generate error P4020:
FUNCTION_BLOCK my_fb
VAR
x : INT;
END_VAR
x := 1;
END_FUNCTION_BLOCK
The source defines a function block but does not contain a PROGRAM declaration, so the compiler has no entry point.
To fix this error, add a PROGRAM declaration:
FUNCTION_BLOCK my_fb
VAR
x : INT;
END_VAR
x := 1;
END_FUNCTION_BLOCK
PROGRAM main
VAR
fb_inst : my_fb;
END_VAR
fb_inst();
END_PROGRAM
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.