1 USING: alien.c-types alien.data strings help.markup help.syntax alien.syntax
2 sequences io arrays kernel words assocs namespaces ;
5 ARTICLE: "c-structs" "C structure types"
6 "A " { $snippet "struct" } " in C is essentially a block of memory with the value of each structure field stored at a fixed offset from the start of the block. The C library interface provides some utilities to define words which read and write structure fields given a base address."
7 { $subsection POSTPONE: C-STRUCT: }
8 "Great care must be taken when working with C structures since no type or bounds checking is possible."
12 "C-STRUCT: XVisualInfo"
13 " { \"Visual*\" \"visual\" }"
14 " { \"VisualID\" \"visualid\" }"
15 " { \"int\" \"screen\" }"
16 " { \"uint\" \"depth\" }"
17 " { \"int\" \"class\" }"
18 " { \"ulong\" \"red_mask\" }"
19 " { \"ulong\" \"green_mask\" }"
20 " { \"ulong\" \"blue_mask\" }"
21 " { \"int\" \"colormap_size\" }"
22 " { \"int\" \"bits_per_rgb\" } ;"
24 "C structure objects can be allocated by calling " { $link <c-object> } " or " { $link malloc-object } "."
26 "Arrays of C structures can be created with the " { $vocab-link "specialized-arrays" } " vocabulary." ;
28 ARTICLE: "c-unions" "C unions"
29 "A " { $snippet "union" } " in C defines a type large enough to hold its largest member. This is usually used to allocate a block of memory which can hold one of several types of values."
30 { $subsection POSTPONE: C-UNION: }
31 "C union objects can be allocated by calling " { $link <c-object> } " or " { $link malloc-object } "."
33 "Arrays of C unions can be created with the " { $vocab-link "specialized-arrays" } " vocabulary." ;