Mapping of Basic Types
Within IDL, the IDL data types are mapped into data types supported by the C language. Most of the types map directly into C primitives, while IDL_TYP_COMPLEX, IDL_TYP_DCOMPLEX, and IDL_TYP_STRING are defined as C structures. The mappings are given in the following table. Structures are built out of the basic types by laying them out in memory in the specified order using the same alignment rules used by the C compiler for the target machine.
Unsigned Byte Data
UCHAR is defined to be unsigned char in idl_export.h.
Integer Data
IDL_INT represents the signed 16-bit data type and is defined in idl_export.h.
Unsigned Integer Data
IDL_UINT represents the unsigned 16-bit data type and is defined in idl_export.h.
Long Integer Data
IDL long integers are defined to be 32-bits in size. The C long data type is not correct on all systems because C compilers for 64-bit architectures usually define long as 64-bits. Hence, the IDL_LONG typedef, declared in idl_export.h is used instead.
Unsigned Long Integer Data
IDL_ULONG represents the unsigned 32-bit data type and is defined in idl_export.h.
64-bit Integer Data
IDL_LONG64 represents the 64-bit data type and is defined in idl_export.h.
Unsigned 64-bit Integer Data
IDL_ULONG64 represents the unsigned 64-bit data type and is defined in idl_export.h.
Complex Data
The IDL_TYP_COMPLEX and IDL_TYP_DCOMPLEX data types are defined by the following C declarations:
This is the same mapping used by Fortran compilers to implement their complex data types, which allows sharing binary data with such programs.
String Data
The IDL_TYP_STRING data type is implemented by a string descriptor:
typedef struct {
IDL_STRING_SLEN_T slen; /* Length of string */
short stype; /* Type of string */
char *s; /* Pointer to string */
} IDL_STRING;
The fields of the IDL_STRING struct are defined as follows:
slen
The length of the string, not counting the null termination. For example, the string "Hello" has 5 characters.
stype
If stype is zero, the string pointed at by s (if any) was not allocated from dynamic memory, and should not be freed. If non-zero, s points at a string allocated from dynamic memory, and should be freed before being replaced. For information on dynamic memory, see Dynamic Memory and Getting Dynamic Memory.
s
If slen is non-zero, s is a pointer to a null-terminated string of slen characters. If slen is zero, s should not be used. The use of a string pointer to memory located outside the IDL_STRING structure itself allows IDL strings to have dynamically-variable lengths.
Note
Strings are the most complicated basic data type, and as such, are at the root of more coding errors than the other types. See IDL Internals: String Processing.