Referring to a Type with typeof

Referring to a Type with typeof

Content #

typeof有两种用法:

  1. 作用于表达式:
typeof (x[0](1))

This assumes that x is an array of pointers to functions; the type described is that of the values of the functions.

  1. 作用于类型:
typeof (int *)

Here the type described is that of pointers to int.

typeof定义maximum宏:

#define max(a,b) \
  ({ typeof (a) _a = (a); \
      typeof (b) _b = (b); \
    _a > _b ? _a : _b; })

From #