On 9/20/07, Simion Stoilow <[EMAIL PROTECTED]> wrote:
> I don't see why you cannot use sizeof on such an expression. The conditional
> expression's result is evaluated to a constant on which the sizeof operator
> is applied...
> Nevertheless, I don't have a copy of the standard so I can only make
> assumptions. Didn't find much about this on the internet either.
This is from one of the latter day ANSI C Drafts (they are available
via the Links section of this Yahoo Group --drafts are free, finals
are not). What happens if you evaluate the expression and then use
sizeof on the result? I think that's a clearer and easier to debug way
of coding it in the first place.
6.5.3.4 The sizeof operator
Constraints
[#1] The sizeof operator shall not be applied to an
expression that has function type or an incomplete type, to
the parenthesized name of such a type, or to an lvalue that
designates a bit-field object.
Semantics
[#2] The sizeof operator yields the size (in bytes) of its
operand, which may be an expression or the parenthesized
name of a type. The size is determined from the type of the
operand. The result is an integer. If the type of the
operand is a variable length array type, the operand is
evaluated; otherwise, the operand is not evaluated and the
result is an integer constant.
[#3] When applied to an operand that has type char, unsigned
char, or signed char, (or a qualified version thereof) the
result is 1. When applied to an operand that has array
type, the result is the total number of bytes in the
array.73) When applied to an operand that has structure or
union type, the result is the total number of bytes in such
an object, including internal and trailing padding.
[#4] The value of the result is implementation-defined, and
its type (an unsigned integer type) is size_t, defined in
the <stddef.h> header.
-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
If I were to divulge it, it would overturn the world."
-- Jelaleddin Rumi