Next: Complex Type Example, Previous: Type Example, Up: Types [Index]

#### 2.3.6 Complex Types

`libffi` supports the complex types defined by the C99 standard (`_Complex float`, `_Complex double` and `_Complex long double` with the built-in type descriptors `ffi_type_complex_float`, `ffi_type_complex_double` and `ffi_type_complex_longdouble`.

Custom complex types like `_Complex int` can also be used. An `ffi_type` object has to be defined to describe the complex type to `libffi`.

Data type: ffi_type ¶
  `size_t size`

    This must be manually set to the size of the complex type.

  `unsigned short alignment`

    This must be manually set to the alignment of the complex type.

  `unsigned short type`

    For a complex type, this must be set to `FFI_TYPE_COMPLEX`.

  `ffi_type **elements`

    This is a ‘`NULL`’-terminated array of pointers to `ffi_type` objects. The first element is set to the `ffi_type` of the complex’s base type. The second element must be set to `NULL`.

The section Complex Type Example shows a way to determine the `size` and `alignment` members in a platform independent way.

For platforms that have no complex support in `libffi` yet, the functions `ffi_prep_cif` and `ffi_prep_args` abort the program if they encounter a complex type.