The C-FFI's C interface description language does not model all of the ways of defining new types in C, but all C types should be expressible in it. As a simplification, we do not support anonymous base types in the C interface description language. If a structure or union field has an in-line type definition in C, that definition must be extracted and given a name in order for it to be used. For example, the following C struct
struct something {
char *name;
long flags;
union {
long int_val;
char *string_val;
} val;
}
can be described with these definitions:
define C-union <anonymous-union-1> slot int-val :: <C-long>; slot string-val :: <C-string>; end C-union; define C-struct <anonymous-struct-1> slot name :: <C-string>; slot flags :: <C-long>; slot val :: <anonymous-union-1>; end C-struct;
The slots of these ex-inline types must be accessed through a chain of accesses, for example o.val.string-val.