PreviousNext

Type Declarations

To support application development in a variety of languages and to support the special needs of distributed applications, IDL provides an extensive set of data types, including the following:

· Simple types, such as integers, floating-pointing numbers, characters, Booleans, and the primitive binding-handle type handle_t (usually equivalent to rpc_binding_handle_t)

· Predefined types, including ISO international character types and the error status type error_status_t

· Constructed types, such as strings, structures, unions, arrays, pointers, and pipes

The IDL typedef declaration lets you give a name to any types you construct.

The general form of a type declaration is

typedef [type_attribute,...] type_specifier type_declarator,...;

where the bracketed list of type attributes is optional. The type_specifier specifies a simple type, a constructed type, a predefined type, or a type previously named in the interface. Each type_declarator is a name for the type being defined. As in C, arrays and pointers are declared by the type_declarator constructs [ ] (brackets) and * (asterisk).

The following type declaration uses the IDL's simple data type, long (a 32-bit data type), to define the integer32 integer type:

typedef long integer32;

The type_specifier constructs for structures and unions permit the application of attributes to members. In the following example, one member of a structure is a conformant array (an array without a fixed upper bound), and the size_is attribute names another member of the structure that at runtime provides information about the size of the array:

typedef struct {

long dsize;

[size_is(dsize)] float darray[];

} dataset;