Limitations

TwinCAT 3 C++ modules are executed in Windows kernel mode. Developers must therefore be aware of some limitations:

TwinCAT functions as replacement for Win32 API functions

The original Win32 API is not available in Windows kernel mode. For this reason a list of the common functions of the Win32 API and their equivalents for TwinCAT is provided here:

Win32API

TwinCAT functionality

WinSock

TF6311 TCP/UDP real-time

Message boxes

Tracing

File I/O

See Interface ITcFileAccess, Interface ITcFileAccessAsync and Sample19: Synchronous File Access, Sample20: FileIO-Write, Sample20a: FileIO-Cyclic Read / Write

Synchronization

See Sample11a: Module communication: C module calls a method of another C module

Visual C CRT

See RtlR0.h

RTTI dynamic_cast function in TwinCAT

TwinCAT has no support for dynamic_cast<>.

Instead, it may be possible to use the TCOM strategy. Define an ICustom interface, which is derived from ITcUnknown and contains the methods, which are called from a derived class. The base class CMyBase is derived from ITcUnknown and implements this interface. The class CMyDerived is derived from CMyBase and from ICustom. It overwrites the TcQueryInterface method, which can then be used instead of dynamic cast.

TcQueryInterface can also be used to display the IsType() function through evaluation of the return value.

See Interface ITcUnknown.