[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


The __typeof__() and typeof() operators

With the __typeof__() operator, CodeWarrior C allows you to a specify a data type of an expression. Listing 3.6 shows an example.

A __typeof__() expression has the form


  __typeof__(expression)

where expression is any valid C expression or data type. The compiler translates a __typeof__() expression into a data type, so it can be used wherever a normal type would be specified.

Like the sizeof() operator, __typeof__() is only evaluated at compile-time, not at runtime. For related information, see "Sizeof() Operator."

When the gcc_extensions pragma is on, a new operator, typeof(), is equivalent to the __typeof__() operator.

Example of __typeof__() and typeof() operators:
char *cp;
int *ip;
long *lp;

typeof(*cp) c; /* equivalent to "char c;" */

#pragma gcc_extensions on
__typeof__(*ip) i; /* equivalent to "int i;" */
__typeof__(*lp) l; /* equivalent to "long l;" */


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000