Defines a simple compound data type.
Struct struct_name [ type_list ] [ Is base_type ] [ Where generic_constraints ] … element_name As element_type … [ statements ] End [ Struct ]
- Mandatory name for the structure.
- Optional. See Type List for more information.
- Optional value type:
an elementary data type (
Intfor example) or the name of a different structure.
- Optional, repeatable. See Where Clause (Generics) for more information.
- Mandatory name for an element of the structure.
- Mandatory value type: an elementary data type or the name of a different structure.
- Optional procedure declarations.
- Completes the statement.
You can also use
- You can change this part of the syntax. See @Option Directive for more information.
Struct is short for “structure”.
You can put a structure only in some locations.
These locations include modules (
Library), and declarations of
You cannot put a structure in a procedure.
See Declaration Contexts and Default Access Levels for more information.
A bit field is an integer member whose size in bits is specified in code.
You use the
UBits data types only within a
You must supply the size between parentheses immediately after
The size must be an integer literal in the range 1 thru 128.
UBits is short for “unsigned bit field”.
SBits is short for “signed bit field”.
When you use
SBits, the most significant bit is reserved as a sign bit.
A base type is most useful when used with bit fields. When you provide a base type, you set the size of the structure. If the combined sizes of the members is more than the size of the base type, this is an error. If the size of the members is less than the base type, then there are unused bits known as padding.
If a structure mixes bit fields and named types, the named types will usually be placed on boundaries. The type of CPU sets the boundaries, counted from the start of the Struct: Intel processors usually have 8-bit boundaries, while Motorola processors usually have 16-bit boundaries. A bit field must not go across a boundary.
Struct point x As Real64 y As Real64 End Struct