Structures

A structure is an aggregate object, which contains one or more sub-objects (members) which are potentially of different types. This code shows some examples of structure definitions and declarations:

// create named structure type 'struct s1'
struct s1 { 
   int x,y; 
};

// create two objects: 'a' is of type 'struct s1', 'b' is of type 'array[4] of struct s1'
struct s1 a, b[4];

// create objects 'c' and 'd'; both are of type 'array[3] of struct s1'
struct s1[3] c, d;

// create an anonymous structure type, and objects 'e' and 'f' of that type
struct { 
   bit4 a;
   var6 b;
   struct s2 {
      var32 x,y;
   } c[2]; 
} e, f;

// create named structure type 'struct s3', and objects 'g' and 'h' of that type
struct s3 { int x,y; } g;
struct s3 h;

Structures may be passed to, and returned from, functions. Structures which are assignment-compatible support a number of operations, including assignment and comparison.

Maia structures are essentially identical to C structures, except that they may not contain incomplete arrays, and C99 named member initialisation is not supported. The comparison operators are supported in Maia, but not in C.