138
Incorporation of C-Functions as CoDeSys Library
12.2.2
Structures
Structures can also be transferred. In doing so, it is important that the data types
be maintained exactly. The structures must also be defined with the "packed"
attribute. Therefore, the following CoDeSys structure
TYPE t_teststruct :
STRUCT
END_STRUCT
END_TYPE
Figure 66: "Example.lib" file
would appear in C as follows:
struct t_teststruct{
char a;
unsigned short b;
signed short c;
unsigned int d;
float e;
char *f;
} __attribute__((packed));
Figure 67: "Example.h" file
Pay attention to the data types and the "packed" attribute in the "Beispiel.h" file.
a : BYTE;
b : WORD;
c : INT;
d : DWORD;
e : REAL;
f : POINTER TO STRING;
758-874/000-110 WAGO-I/O-IPC-C6
// Codesys-Style:
//
BYTE
//
WORD
//
INT
//
DWORD
//
REAL
//
POINTER TO STRING
WAGO-I/O-SYSTEM 750
Manual
Version 2.3.0