STRUCT:
Factor handbook » C library interface » Passing data between Factor and C » C type specifiers

Next:UNION-STRUCT:


Vocabulary
classes.struct

Syntax
STRUCT: class { slot type } { slot type } ... ;


Inputs
None

Outputs
None

Word description
Defines a new struct type. The syntax is nearly identical to TUPLE:; however, there are some additional restrictions on struct types:
Struct classes cannot have a superclass defined.
The slots of a struct must all have a type declared. The type must be a C type.
read-only slots on structs are not enforced, though they may be declared.

Additionally, structs may use bit fields. A slot specifier may use the syntax bits: n to specify that the bit width of the slot is n. Bit width may be specified on signed or unsigned integer slots. The layout of bit fields is not guaranteed to match that of any particular C compiler.

See also
struct, UNION-STRUCT:

Definition