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: Enable C-style comments

If you prefer to use C-style comments, enable them.

Pass the --allow-c-style-comments flag to enable it, or select a dialect that includes it. See Enabling Dialects and Features for the dialects and flags reference.

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.