Next: , Previous: defcstruct, Up: Foreign Types


defcunion

Syntax

— Macro: defcunion name &body doc-and-slots ⇒ name

doc-and-slots ::= [docstring] { (slot-name slot-type &key count) }*

Arguments and Values

name
The name of new union type.
docstring
A documentation string, ignored.
slot-name
A symbol naming the slot.
slot-type
The type specifier for the slot.
count
Used to declare an array of size count inside the structure.

Description

A union is a structure in which all slots have an offset of zero. It is isomorphic to the C union. Therefore, you should use the usual foreign structure operations for accessing a union's slots.

Examples

  (defcunion uint32-bytes
    (int-value :unsigned-int)
    (bytes :unsigned-char :count 4))

See Also

foreign-slot-pointer
foreign-slot-value