All Manuals > LispWorks Foreign Language Interface User Guide and Reference Manual > 5 Function and Macro Reference

NextPrevUpTopContentsIndex

define-c-union

Macro
Summary

Defines a FLI union type corresponding to the C union type.

Package

fli

Signature

define-c-union name-and-options &rest slot-descriptions => list

name-and-options ::= name | ( name option *)

option ::= (:foreign-name string )

slot-descriptions ::= { slot-name | ( slot-name slot-type )}*
Arguments

name

A symbol naming the new union type descriptor

string

A string specifying the foreign name of the type

slot-descriptions

A sequence of symbols, possibly with type descriptions, naming the slots of the union.

slot-name

A symbol naming the slot.

slot-type

The FLI type of the slot.

Values

list

The list (:union name ) .

Description

The macro define-c-union is used to define a FLI union type specifier, which corresponds to the C union type. It is a convenience function, as a union type could also be defined using define-foreign-type.

A union is an aggregate type, or collection, of other FLI types. The types contained in a union are referred to as slots, and can be accessed using the foreign-slot-type and foreign-slot-value functions.

Example

In the following example a union is defined using define-c-union , and the corresponding C code is given.

(fli:define-c-union a-point (x :int)
                            (color :byte)
                            (ident :char))
union a-point {
  int x;
  byte color;
  char ident;
};
See also

define-c-enum
define-c-struct
define-c-typedef
define-foreign-type
FLI Types


LispWorks Foreign Language Interface User Guide and Reference Manual - 7 Dec 2011

NextPrevUpTopContentsIndex