138
Some more examples of the use of
This declares
with the type of what
•
y
typeof (*x) y;
This declares
as an array of such values.
•
y
typeof (*x) y[4];
This declares
as an array of pointers to characters:
•
y
typeof (typeof (char *)[4]) y;
It is equivalent to the following traditional C declaration:
char *y[4];
To see the meaning of the declaration using
rewrite it with these macros:
#define pointer(T)
#define array(T, N) typeof(T [N])
Now the declaration can be rewritten this way:
array (pointer (char), 4) y;
Thus,
array (pointer (char), 4)
Compatibility Note: In addition to
ted one to write
typedef
=
T
expr
with the effect of declaring
with GCC 3 (versions between 3.0 and 3.2 will crash; 3.2.1 and later give an error). Code which relies
on it should be rewritten to use
typedef typeof(
expr
This will work with all versions of GCC.
6.7. Generalized Lvalues
Compound expressions, conditional expressions and casts are allowed as lvalues provided their
operands are lvalues. This means that you can take their addresses or store values into them. All
these extensions are deprecated.
Standard C++ allows compound expressions and conditional expressions as lvalues, and permits casts
to reference type, so use of this extension is not supported for C++ code.
For example, a compound expression can be assigned, provided the last expression in the sequence is
an lvalue. These two expressions are equivalent:
(a, b) += 5
a, (b += 5)
typeof
x
typeof(T *)
typeof
;
to have the type of the expression
T
:
typeof
)
;
T
Chapter 6. Extensions to the C Language Family
:
points to.
, and why it might be a useful way to write,
typeof
is the type of arrays of 4 pointers to
, GCC 2 supported a more limited extension which permit-
.
char
. This extension does not work
expr
Need help?
Do you have a question about the ENTERPRISE LINUX 4 and is the answer not in the manual?