Creating instances of structs
Factor handbook > C library interface > Struct classes

Prev:Defining struct classes
Next:Passing structs to C functions


Structs can be allocated with new- and boa-like constructor words. Additional words are provided for building structs from C memory and from existing buffers:
<struct> ( class -- struct )

<struct-boa> ( class -- quot: ( ... -- struct ) )

malloc-struct ( class -- struct )

memory>struct ( ptr class -- struct )


When the contents of a struct will be immediately reset, faster primitive words are available that will create a struct without initializing its contents:
(struct) ( class -- struct )

(malloc-struct) ( class -- struct )


Structs have literal syntax, similar to T{ for tuples:
S{