HP Pascal/iX Reference Manual (31502-90022)

11- 43
tag_value
The name of a case constant in the variant part of a
record declaration. Case constants for nested
variants may appear separated by commas.
type_name
The name of a type.
record_type_name
The name of a record type with variants.
struct_constant
The name of an array, record, set, or string
constructor.
string_literal
A string literal.
The predefined function sizeof returns the number of bytes of storage
required to represent the data value part of a data item of the given
type, or the actual allocated size of a variable. If the first parameter
is a record type or variable with variants, a variant may be selected by
specifying a case constant with the subsequent parameters. sizeof
(type)
returns the minimum number of bytes for the type. sizeof
(variable)
returns the number of bytes of storage for the variable. Otherwise, the
size of the largest variant is returned.
For a variable of a simple data type, the number returned by sizeof is
equivalent to the storage required for the variable in the unpacked
context. For example, if the variable is type char or Boolean, sizeof
returns 1.
For an ANYVAR parameter, two cases exist: If an additional hidden size
parameter is passed along with the ANYVAR parameter, sizeof gives the
actual number of bytes allocated to represent the actual parameter. If
the hidden length parameter is not passed, sizeof gives the number of
bytes required to represent the formal parameter.
For conformant array parameters, the function sizeof is the actual size
of the parameter.
Example
TYPE
byte = 0..255;
big_record = RECORD CASE Boolean OF
true: ( arr : array [ 1..200 ] of byte ):
false: ( f1 : integer;
...
f99 : char );
BEGIN
...
IF (sizeof(big_record,true) <> sizeof(big_record,false)) THEN
BEGIN
writeln ( 'variant size mismatch by',
abs(sizeof(big_record,true)-sizeof(big_record,false)):1,
'bytes' );
HALT (1);
END;
...
END.
NOTE sizeof is allowed in CONST sections except for ANYVAR, VAR s, and
conformant array parameters.