typeof() Operator

When the GCC extensions setting is on, the compiler recognizes the typeof() operator. This compile-time operator returns the type of an expression. You may use the value returned by this operator in any statement or expression where the compiler expects you to specify a type. The compiler evaluates this operator at compile time. The __typeof()__ operator is the same as this operator. The following listing shows an example.

Listing: Using the typeof() operator

int *ip;
/* Variables iptr and jptr have the same type. */

typeof(ip) iptr;

int *jptr;

/* Variables i and j have the same type. */

typeof(*ip) i;

int j;