P0004

Code

P0004

Message

C-style comment not allowed

This error occurs when C-style comments (//) are used in the code, which are not allowed in IEC 61131-3.

Example

The following code will generate error P0004:

FUNCTION_BLOCK Example
VAR
    Counter : INT;
END_VAR

// This is a C-style comment  (* Error: C-style comments not allowed *)
Counter := Counter + 1;
END_FUNCTION_BLOCK

The code uses // for comments, which is C-style syntax and not valid in IEC 61131-3.

To fix this error, you have two options:

Option 1: Use proper IEC 61131-3 comment syntax

FUNCTION_BLOCK Example
VAR
    Counter : INT;
END_VAR

(* This is a proper IEC 61131-3 comment *)
Counter := Counter + 1;
END_FUNCTION_BLOCK

Option 2: Choose a dialect that supports C-style comments

If you prefer to use C-style comments, select a dialect that supports them. The rusty and codesys dialects both enable C-style comments (choose one from the dialect selector in the playground, or pass --dialect rusty on the command line). You can also enable just this feature with the --allow-c-style-comments command line option.

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.