ironplcc¶
Name¶
ironplcc — IronPLC compiler
Synopsis¶
Description¶
ironplcc is the IronPLC compiler command line interface. It checks
IEC 61131-3 source files for correctness and compiles them into bytecode
container (.iplc) files for execution by the ironplcvm runtime.
Most developers will use ironplcc through the Visual Studio Code extension, but you can also use it directly, for example, to implement a continuous integration pipeline.
When a command accepts multiple files, the files are treated as a single compilation unit (essentially combined for analysis). Directory names can be given to add all files in the given directory.
See also
See Source Formats for all supported source file formats.
Commands¶
Build Commands¶
- ironplcc check [FILES…]
Check source files for syntax and semantic correctness without producing output. On success, the command produces no output.
- ironplcc compile [FILES…]
-oOUTPUT Compile source files into a bytecode container (
.iplc) file. Requires the--output(-o) flag to specify the output file path.Note
The compile command supports Structured Text programs, including functions, function blocks, the standard library, and activated compatibility libraries. A program that uses a feature code generation does not yet support produces a code generation error rather than incorrect bytecode.
Diagnostic Commands¶
- ironplcc echo [FILES…]
Parse source files and write the parsed representation to standard output. This is primarily useful for diagnostics and understanding the internal structure of the parsed files.
- ironplcc tokenize [FILES…]
Tokenize source files and verify that all content matches a token. This is primarily useful for diagnostics and understanding the lexer behavior.
Informational Commands¶
- ironplcc dialects
Show available dialects and which features each enables. Use this to discover which
--allow-*flags a dialect includes.- ironplcc version
Print the version number of the compiler.
Other Commands¶
- ironplcc lsp
--stdio Run in Language Server Protocol mode to integrate with development tools such as Visual Studio Code. Communication uses standard input/output.
Options¶
-v,--verboseTurn on verbose logging. Repeat the flag to increase verbosity (e.g.,
-vvv).-lFILE,--log-fileFILEWrite log output to the specified file instead of the terminal.
--dialectDIALECTSelect the language dialect. A dialect sets the IEC 61131-3 edition and a default set of extensions. Individual
--allow-*flags can override the dialect’s defaults. Available values:iec61131-3-ed2(default),iec61131-3-ed3,rusty,codesys,twincat. See Enabling Dialects and Features for details.--libraryNAMEActivate a compatibility library by name (for example
--library Tc2_System). Repeat the option to activate several libraries. Applies to thecheckandcompilecommands. Libraries referenced by a discovered project file are activated automatically and do not need this option.--allow-c-style-commentsAllow C-style comments (
//line comments and/* */block comments). This is an extension not part of the IEC 61131-3 standard.--allow-missing-semicolonAllow missing semicolons after keyword statements like
END_IFandEND_STRUCT. This is an extension not part of the IEC 61131-3 standard.--allow-top-level-var-globalAllow
VAR_GLOBALdeclarations at the top level of a file, outside of aCONFIGURATIONblock. This is an extension not part of the IEC 61131-3 standard.--allow-constant-type-paramsAllow constant references in type parameters (e.g.,
STRING[MY_CONST]orARRAY[1..MY_CONST] OF INT). This is an extension not part of the IEC 61131-3 standard.--allow-empty-var-blocksAllow empty variable blocks (
VAR END_VAR,VAR_INPUT END_VAR, etc.). This is an extension not part of the IEC 61131-3 standard.--allow-time-as-function-nameAllow
TIMEto be used as a function name (e.g.,TIME()). Required for OSCAT compatibility. This is an extension not part of the IEC 61131-3 standard.--allow-long-time-typesAllow the IEC 61131-3:2013 long-time-type keywords
LTIME,LDATE,LTIME_OF_DAY(LTOD), andLDATE_AND_TIME(LDT). Without this flag those words remain available as ordinary identifiers.--allow-ref-toAllow
REF_TO,REF(), andNULLsyntax (standardized in IEC 61131-3:2013) without enabling the rest of Edition 3. This is useful when you need references but want to keep Edition 2 keyword handling for the rest of your code.--allow-reference-toAllow the Beckhoff TwinCAT / CODESYS
REFERENCE TOreference type and theREF=binding operator — the TwinCAT/CODESYS-facing alternative to--allow-ref-to.--allow-pointer-toAllow the Beckhoff TwinCAT / CODESYS
POINTER TOpointer type with explicit dereference (^).--allow-adrAllow the
ADR()address-of operator, which returns a typed pointer to a variable for assignment to aPOINTER TOvariable.--allow-ref-arithmeticAllow arithmetic (
+,-) and ordering comparisons (<,>,<=,>=) onREF_TOtypes. By default, only=and<>are permitted on references.--allow-ref-stack-variablesAllow
REF()on stack-allocated variables (VAR_TEMPand functionVAR_INPUT/VAR_OUTPUT). This is an extension not part of the IEC 61131-3 standard.--allow-ref-type-punningAllow assigning between
REF_TOtypes of different base types (type punning). This is an extension not part of the IEC 61131-3 standard.--allow-int-to-bool-initializerAllow integer literals
0and1asBOOLvariable initializers, treating0asFALSEand1asTRUE. This is a dialect extension supported by CoDeSys, TwinCAT, RuSTy, and virtually every PLC runtime.--allow-sizeofAllow the
SIZEOF()operator that returns the size in bytes of a variable or type. This is an extension supported by CODESYS, TwinCAT, and RuSTy.--allow-system-uptime-globalExpose
__SYSTEM_UP_TIME(TIME) and__SYSTEM_UP_LTIME(LTIME) as implicitVAR_GLOBALvalues holding the VM’s monotonic uptime. This is an IronPLC runtime convention.--allow-cross-family-wideningAllow implicit widening between bit-string and integer type families (e.g.
BYTEtoINT, literal0toBYTE). This is a dialect extension supported by CODESYS, TwinCAT, and RuSTy.--allow-partial-access-syntaxAllow IEC 61131-3:2013 partial-access bit syntax (
.%Xn) as an alias for the short form.n. Byte/word/dword/lword partial access (.%Bn,.%Wn,.%Dn,.%Ln) is not yet supported.--allow-pragmasAllow curly-brace pragmas such as
{attribute 'qualified_only'}. This is CODESYS-core syntax, inherited by TwinCAT and other CODESYS-based IDEs. A pragma is parsed and discarded like a comment; its contents are not interpreted.--allow-short-circuit-operatorsAllow the
AND_THENandOR_ELSEshort-circuit boolean operators, a Beckhoff/CODESYS extension.AND_THENevaluates its right operand only when the left operand isTRUE;OR_ELSEonly when the left operand isFALSE. Bit-string operands have nothing to short-circuit on and evaluate both operands, matchingANDandOR.--allow-mixed-located-var-declarationsAllow an
AT-located variable (e.g.AT %I*) inside an otherwise plainVAR/VAR_INPUT/VAR_OUTPUTblock, instead of requiring its own dedicated block. Produces P4036 when mixed without this flag.--allow-constant-initializer-expressionsAllow a
VARinitializer to be a constant expression (e.g.scaled : LREAL := SCALE*4.0;) rather than only a bare literal. Folded to a literal at compile time; produces P4037 when used without this flag, or P4038 if the expression does not fully reduce to a constant.--allow-bit-string-case-labelsAllow a hex, binary, or octal bit-string literal (e.g.
16#D012,2#1010) as aCASElabel. The IEC 61131-3 standard permits only a subrange, decimal integer, or enumerated value here. Produces P4041 when used without this flag.--allow-paren-string-lengthAllow a string type’s maximum length to be delimited with parentheses (
STRING(255),WSTRING(100)) in addition to the standard square brackets. The IEC 61131-3 standard declares a string length only with brackets; the parenthesis form is an extension. Produces P4042 when used without this flag.--allow-struct-initializer-expressionsAllow a general (non-constant) expression — such as a pointer dereference plus member access (
pDevice^.Delta) — as the value in a structured or call-style initializer’sname := valuepairs (e.g.tonDelta : TON := (PT := pDevice^.Delta);). The IEC 61131-3 standard permits only a constant, enumerated value, array initializer, or nested structure initializer here; this extension accepts a value computed at instantiation time. Produces P4043 when used without this flag.--allow-fb-inheritanceAllow the IEC 61131-3:2013 object-oriented syntax:
EXTENDS/IMPLEMENTS/ABSTRACTonFUNCTION_BLOCKdeclarations,INTERFACEdeclarations,METHODdeclarations, andTHIS/SUPER. Support beyond parsing varies by keyword — see Object Oriented Programming; the parts that are parsed but not yet analyzed produce P9999. Enabled by--dialect=iec61131-3-ed3,--dialect=rusty,--dialect=codesys, and--dialect=twincat.
Examples¶
Check a source file for correctness:
ironplcc check main.st
Check all files in a directory:
ironplcc check src/
Compile a source file to a bytecode container:
ironplcc compile main.st -o main.iplc
Compile with verbose logging to a file:
ironplcc -vv --log-file build.log compile main.st -o main.iplc
Inspect the parsed representation of a file:
ironplcc echo main.st
Check a source file using IEC 61131-3:2013 (Edition 3) features:
ironplcc check --dialect iec61131-3-ed3 main.st
Show available dialects and their features:
ironplcc dialects
See Also¶
ironplcvm — IronPLC virtual machine runtime
Overview — Getting started tutorial
Source Formats — Supported source file formats
Problem Codes — Compiler problem code index