In section 6.7.5.2 it states the following:
If the size is not present, the array type is an incomplete type. If
the size is*instead of
being an expression, the array type is a variable length array type of
unspeciï¬ed size,
which can only be used in declarations with function prototype
scope;124) such arrays are
nonetheless complete types. If the size is an integer constant
expression and the element
type has a known constant size, the array type is not a variable length
array type;
otherwise, the array type is a variable length array type.
5 If the size is an expression that is not an integer constant
expression: if it occurs in a
declaration at function prototype scope, it is treated as if it were
replaced by*;otherwise,
each time it is evaluated it shall have a value greater than zero. The
size of each instance
of a variable length array type does not change during its lifetime.
Where a size
expression is part of the operand of a sizeof operator and changing the
value of the
size expression would not affect the result of the operator,
itisunspeciï¬e d whether or not
the size expression is evaluated.
but I am having problems understanding the purpose of an incomplete
type. What is the purpose and why would someone use one rather than
specifying an int for the size of the VLA?
How does it affect the operation of the array? Does it change how it is
treated by the program?
Thanks for any help.
--
"I disapprove of what you say, but I'll defend to the death your right
to say it." - Voltaire
If the size is not present, the array type is an incomplete type. If
the size is*instead of
being an expression, the array type is a variable length array type of
unspeciï¬ed size,
which can only be used in declarations with function prototype
scope;124) such arrays are
nonetheless complete types. If the size is an integer constant
expression and the element
type has a known constant size, the array type is not a variable length
array type;
otherwise, the array type is a variable length array type.
5 If the size is an expression that is not an integer constant
expression: if it occurs in a
declaration at function prototype scope, it is treated as if it were
replaced by*;otherwise,
each time it is evaluated it shall have a value greater than zero. The
size of each instance
of a variable length array type does not change during its lifetime.
Where a size
expression is part of the operand of a sizeof operator and changing the
value of the
size expression would not affect the result of the operator,
itisunspeciï¬e d whether or not
the size expression is evaluated.
but I am having problems understanding the purpose of an incomplete
type. What is the purpose and why would someone use one rather than
specifying an int for the size of the VLA?
How does it affect the operation of the array? Does it change how it is
treated by the program?
Thanks for any help.
--
"I disapprove of what you say, but I'll defend to the death your right
to say it." - Voltaire
Comment