You are on page 1of 2

I apologize for any confusion.

You are correct that writing and compiling C++ programs directly
within the TwinCAT development environment without Visual Studio Professional is not officially
supported.

TwinCAT primarily focuses on IEC 61131-3 languages such as Structured Text (ST), Function
Block Diagram (FBD), and ladder diagram (LD) for PLC programming. While TwinCAT does
have some limited support for C++, it is typically intended for creating C++ libraries that can be
used within the TwinCAT system.
To fully utilize C++ features, advanced debugging capabilities, and third-party libraries, it is
recommended to use Visual Studio Professional in conjunction with TwinCAT for C++
programming. Visual Studio Professional provides a complete C++ development environment with
comprehensive features, including code editing, debugging, and project management tools.
By integrating TwinCAT with Visual Studio Professional, you can leverage the full power of Visual
Studio for C++ development while benefiting from the TwinCAT system's PLC and motion control
capabilities.

To write C++ programs in TwinCAT without using Visual Studio Professional, you can make use of
the TwinCAT development environment itself, which includes a basic code editor and C++
compiler. Although it may not provide the same advanced features as Visual Studio Professional, it
still allows you to write and compile C++ code.

Here's a step-by-step guide to writing C++ programs in TwinCAT without Visual Studio
Professional:

1. Launch the TwinCAT development environment: Open TwinCAT and create a new project
or open an existing one.
2. Add a new C++ file: Right-click on the project in the Solution Explorer and select "Add
New Item." Choose "Text File" and give it a .cpp extension, such as myprogram.cpp .

3. Write your C++ code: Double-click on the newly added .cpp file to open the code editor.
Write your C++ code in the editor. You can use standard C++ syntax and constructs.
4. Build the project: After writing the C++ code, build the project by clicking on the "Build"
menu and selecting "Build Solution" or pressing the corresponding shortcut key (e.g., F5).
5. Check the build output: The output window will show the build process and any
compilation errors or warnings. If there are errors, review your code and make necessary
corrections.
6. Run the program: If the build is successful, you can run the program within the TwinCAT
runtime environment or simulate the behavior using the available tools.
While the basic code editor in TwinCAT allows you to write and compile C++ code, it's worth
noting that advanced features like code navigation, IntelliSense, and debugging may be limited
compared to using Visual Studio Professional. If you require those advanced features, consider
using Visual Studio Professional in combination with the TwinCAT development environment for
C++ programming in TwinCAT.

You might also like