版本3和4间的区别
于2007-07-19 07:48:42修订的的版本3
大小: 1285
编辑: czk
备注:
于2008-02-23 15:34:53修订的的版本4
大小: 1285
编辑: localhost
备注: converted to 1.6 markup
未发现区别!

A.8.9 Typedef

Declarations whose storage class specifier is typedef do not declare objects; instead they define identifiers that name types. These identifiers are called typedef names.

  • typedef-name:
    • identifier

A typedef declaration attributes a type to each name among its declarators in the usual way (see Par.A.8.6). Thereafter, each such typedef name is syntactically equivalent to a type specifier keyword for the associated type.

For example, after

  • typedef long Blockno, *Blockptr; typedef struct { double r, theta; } Complex;

the constructions

  • Blockno b; extern Blockptr bp; Complex z, *zp;

are legal declarations. The type of b is long, that of bp is pointer to long, and that of z is the specified structure; zp is a pointer to such a structure.

typedef does not introduce new types, only synonyms for types that could be specified in another way. In the example, b has the same type as any long object.

Typedef names may be redeclared in an inner scope, but a non-empty set of type specifiers must be given. For example,

  • extern Blockno;

does not redeclare Blockno, but

  • extern int Blockno;

does.

TCPL/A.08.09_Typedef (2008-02-23 15:34:53由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.