Check TwinCAT 3 Projects¶
This guide shows how to use IronPLC to check a Beckhoff TwinCAT 3 project for correctness — without changing the project.
Note
This guide assumes you have installed the IronPLC Compiler. See Installation if you have not already installed it.
Check a Solution from the Command Line¶
Point IronPLC at the directory that holds your .sln file — or at
the .sln itself — and select the twincat dialect:
ironplcc check --dialect twincat path/to/my-solution
ironplcc check --dialect twincat path/to/my-solution/MySolution.sln
IronPLC follows the solution layout the same way TwinCAT XAE does. It
reads the .sln to find the .tsproj files, each
.tsproj to find the .plcproj PLC projects, and each
.plcproj to find the .TcPOU, .TcGVL,
.TcDUT, and .TcIO files to analyze. A solution that
contains more than one PLC project is checked as a whole, so code in one
project can use types and functions declared in another.
Name the directory that holds the .sln, not a directory above it.
IronPLC does not search subdirectories for a project file. A directory
that holds no .sln or .plcproj is checked as a folder of
loose files instead, which ignores what the project files say — see
TwinCAT for the full rules.
On success, the command produces no output. If there are problems, IronPLC prints diagnostics with the file name, line number, and a description of each problem.
The --dialect twincat option matters: it tells IronPLC to accept the
language extensions that TwinCAT accepts, so TwinCAT-specific syntax works
by default and you do not need to enable individual features. See
Enabling Dialects and Features for how dialects work.
If your project references Beckhoff libraries such as Tc2_System,
IronPLC activates its bundled compatibility libraries automatically — see
Use Beckhoff Libraries.
Check a Single File¶
You can also check individual TwinCAT files:
ironplcc check --dialect twincat MyProgram.TcPOU
Checking a single file is useful for a quick look, but prefer checking the solution directory: only there can IronPLC resolve names declared in other files and read the project’s library references.
Check with the VS Code Extension¶
Open your TwinCAT solution folder in VS Code.
In the settings (), set Ironplc: Dialect to
twincat.Open any TwinCAT source file. The extension highlights errors and warnings in the editor as you type.
See Also¶
TwinCAT — supported file types and how project discovery works
Enabling Dialects and Features — what the
twincatdialect enablesRun TwinCAT 3 Projects Without a PLC — the next step: execute the project