When you declare a structure variable for use with an external subroutine or function, you need to know how ESL structure definitions map to the target language structure definitions. The fields in the structure variable are defined by the structure type. A structure type has no internal header, so the offset of the first field is always zero. All ESL structures do not use packing to align members based on the length of the data type, so to get the offset of any field in a structure, you add up the lengths of all the fields that precede it. We recommend that when defining the structure with the external 'C' code, the "pragma pack" compiler directive is used to set the packing size to 1 byte. As structures used to access Windows API will use the default packing size, once the structure passed between the ESL and external code have been defined, you must restore the packing size to the default.
Whilst not recommended, it is possible to set the default packing size to 1 byte using the compiler option "\Zp1"; however, this will effect all structure, including any that are needed to access Windows API, which may cause corruption.
The following table shows how a field definition translates to a field length, in bytes.
Field Definition |
Length in Bytes |
integer |
4 |
float |
8 |
string |
4 (HSTRING) |
using integer size 1 |
1 |
using integer size 2 |
2 |
using integer |
4 |
using integer size 4 |
4 |
using float size 4 |
4 |
using float |
8 |
using float size 8 |
8 |
using string size N |
N |