Arrays
Array is a composite data object, each element of which has the same type.
dword arr[4];
This construct defines a type arr which consists of four hexadecimal
32-bit words.
The same syntax is used to declare a structure or a union field:
struct Vector {
dword arr[4];
};
It is interesting to note that you can combine the above definitions:
dword arr[4];
struct Vector {
arr arr;
};
There is no identifier conflict because the first arr is the type name,
and the second arr is the field name (this is not a recommended practive though).
Variable size arrays
You can specify a name of a numeric field in the square brackets instead of
a number. The content of the appropriate field will be used as the array dimension.
struct CHUNK {
unsigned dword nElements;
hex dword Element[nElements];
};
For obvious reason you cannot define a variable size array type because no size
field is available on the top declaration level. Variable size arrays are allowed
only as fields within a composite data object (structure
or union).
|