CODESYS Control V3 Manual
2.4 Error Codes
All functions in the runtime system return an error code. This error code has the type RTS_RESULT.
All error codes can be found in CmpErrors.h.
Standard error codes that can be used in each component are defined at the beginning of
CmpErrors.h. Each error code has a prefix with ERR_.
Each kernel component can specify its own error codes in CmpErrors.h.
Each OEM components can specify its own error codes in the range f 0x8000..0xFFFF.
2.5 Object Handles
All handles to data structures or objects have the type RTS_HANDLE. An invalid object can be
checked with RTS_INVALID_HANDLE. All functions that return a handle must additionally return an
error code to the caller to specify the reason of an RTS_INVALID_HANDLE.
2.6 Linkage
All components of the runtime system can be linked together in 3 different ways:
• Static Link: All components are linked together to one executable file (e.g. *.exe). This
executable file is closed, so no additional component can be added afterwards to this package.
• Dynamic Link: Each component is linked here separately to a dynamically loadable module
(e.g. *.dll or *.o). The components are loaded dynamically during startup of the runtime system.
So at every start it can be decided, which components are to be loaded and linked to the
runtime system.
• Mixed Link: This is a mixture of both issues above. The basic components are linked statically
together to one executable file, but can get extended by dynamically loaded components.
How the linkage is done can be specified with compiler flags:
• STATIC_LINK: For static linking
• MIXED_LINK: For mixed linking
• DYNAMIC_LINK (or nothing): This is the default, if none of the two defines above is set
The source code of the components is identical in all linkage models. How this is realized is described
in the next chapter.
2.7 Component Interface Architecture
The component interface of the runtime system must match the following requirements:
1. For embedded targets, all runtime system components should be linked static with direct C-
functions calls in order to have a maximum of performance.
2. For more powerful systems with an operating system, the components should be loaded
dynamically in order to have the flexibility to select components that should be used during
startup time. Here, all functions of other components must be called via function pointers that
are investigated during start up of the system.
3. For C++ runtime systems, the C++ calling conventions (name mangling, virtual function calls,
methods) should be used.
To perform all these issues, 3S has developed an own interface technology based on C-macros.
Every function call must be done not directly with a call of the C-function. You always have to use a
special CAL_ prefix for that.
Additionally the export and import of functions must be done by special EXP_ and GET_ macros.
The usage of these macros is explained in the following:
3S-Smart Software Solutions GmbH Page 18 of 219
CODESYSControlV3_Manual.doc
tech_doc_e.doc / V1.2