Referring To A Type With Typeof - Intel i960 User Manual

Processor compiler
Hide thumbs Also See for i960:
Table of Contents

Advertisement

Language Implementation
This is useful in conjunction with the statements-within-expressions
feature. Here is how the two together can be used to define a safe
"maximum" macro that operates on any arithmetic type:
#define max(a,b) \
({typedef _ta = (a), _tb = (b);
_ta _a = (a); _tb _b = (b);
_a > _b ? _a : _b; })
The reason for using names that start with underscores for the local
variables is to avoid conflicts with variable names that occur within the
expressions that are substituted for

Referring to a Type with typeof

Another way to refer to the type of an expression is with
syntax of using of this keyword looks like
semantically like a type name defined with
There are two ways of writing the argument to
expression or with a type. Here is an example with an expression:
typeof (x[0](1))
This assumes that
is an array of functions; the type described is that of
x
the values of the functions.
Here is an example with a typename as the argument:
typeof (int *)
Here the type described is that of pointers to
If you are writing a header file that must work when included in ANSI C
programs, write
__typeof__
\
\
and
.
a
b
, but the construct acts
sizeof
.
typedef
typeof
.
int
instead of
.
typeof
. The
typeof
: with an
7
7-41

Advertisement

Table of Contents
loading

Table of Contents