1.11.4. Datatypes¶
1.11.4.1. RTS datatypes¶
The runtime system defines its own typesystem based on the portable “ANSI stdint” types (see stdint.h datatypes). The types are defined in CmpStd.h and starts always with RTS_, e.g. RTS_UI32.
Rules:
Use always the predefined RTS_ datatypes in all interfaces!
Additionally you must use it in all implementations, where a fix size is needed (e.g. L7 service in communication)!
For all other internal implementations it is recommended, to use this datatypes too. The only exception for using native datatypes is when calling native OS- or Firmware functions.
- For IEC libraries there are the corresponding IEC type definitions in CmpStd.h:e.g. RTS_IEC_BOOL for an IEC bool value. The types are exported automatically of the m4-Export Tool in CODESYS out of a library. Use the Systems Hungarian notation! That means the datatype of an identifier is described in as a prefix in the name.For example:RTS_UI32 ui32NumOfTasks;All prefixes are described in the tables below.
static variables with s_ as prefix, e.g. static char s_cTag;
- static arrays with a as prefix, e.g. static RTS_UI8 s_aui8Buffer[100];Note: Static arrays have the prefix a to avoid confusing a variable with a pointer p!
Pointers starts with p as prefix, e.g. RTS_UI8 *pui8Buffer;
Function pointers starts with pf as prefix, e.g. INT_HANDLER *pfHandler;
RTS datatypes:
The standard RTS_ datatypes contains the real size Bits, e.g. RTS_I8 (8 Bits). So the corresponding size is identical on every platform!
Datatype |
Prefix |
Size in Bits |
Usage |
|
|---|---|---|---|---|
RTS_I8 |
i8 |
8 |
Signed values |
|
RTS_UI8 |
ui8 |
8 |
Unsigned values |
|
RTS_I16 |
i16 |
16 |
Signed values |
|
RTS_UI16 |
ui16 |
16 |
Unsigned values |
|
RTS_I32 |
i32 |
32 |
Signed values |
|
RTS_UI32 |
ui32 |
32 |
Unsigned values |
|
RTS_I64 |
i64 |
64 |
Signed values |
|
RTS_UI64 |
ui64 |
64 |
Unsigned values |
|
RTS_REAL32 |
r32 |
32 |
Floating point values |
|
RTS_REAL64 |
r64 |
64 |
Floating point values |
|
RTS_WCHAR |
wsz |
16 |
16Bit Unicode character |
The wsz and sz prefixes are for pointers to characters or arrays of characters. Examples:
|
RTS_CSTRING |
sz |
8 |
8Bit ASCII character |
|
There are some special datatypes which usage is explained here:
Datatype |
Prefix |
Size in Bits |
Usage |
|---|---|---|---|
RTS_HANDLE |
h |
Size to hold always a pointer |
For every handle in the runtime system |
RTS_RESULT |
r |
32 |
For error codes |
RTS_UINTPTR |
uiptr |
Size to hold always the address of a pointer |
For pointer arithmetic hold in an unsigned integral type |
RTS_INTPTR |
iptr |
Size to hold always the address of a pointer |
For pointer arithmetic hold in a signed integral type |
RTS_PTRDIFF |
ptrdiff |
Size to hold always a pointer difference for a buffer offset |
Signed integral type that can hold an array index |
RTS_SIZE |
si |
Size to hold always a buffer offset |
Unsigned integral type that can hold a buffer offset |
RTS_TIME |
t |
dependant on the platform (e.g. 32Bit on 32Bit platforms, 64Bit on 64Bit platforms) |
Time to hold a UTC value |
RTS_INT |
i |
Variant size, typical the platform specific int size |
Data type has no constant size, so be careful, in sharing such data types with IEC! |
RTS_BOOL |
b |
Variant size, typical the platform specific int size |
Boolean value (TRUE or FALSE) Data type has no constant size, so be careful, in sharing with IEC! |
1.11.4.2. ANSI/ISO C native datatypes¶
stdint.h datatypes¶
With the ISO standard C99, a new portable typesystem was introduced by stdint.h. See opengroup stdint.h.
We ported the RTS datatypes to this typesystem to be widely portable.
ANSI-C datatypes¶
Native ANSI C89/ISO C89 datatypes should be avoided! They are forbidden in newer interfaces, because they are binary portable! See ANSI C Datatypes for the platform specific ANIC-C datatypes.

