7.1 说明符
7.1 说明符
1、用于声明的说明符包括:
decl-specifier:
storage-class-specifier
type-specifier
function-specifier
friend
typedef
decl-specifier-seq:
decl-specifier-seqopt decl-specifier
2、最长的decl-specifiers序列被当作declaration的decl-specifier-seq。如下所示,这个序列应该是自相容。例如:
typedef char* Pc;
static Pc; // error: name missing
此处,声明static Pc是非法的,因为没有为类型为Pc的静态变量指定名字。为了将Pc声明为变量,必须给出type-specifier(而不是const或volatile)以说明类型定义名Pc不再是decl-specifier序列的一部分,而被(重新)声明为变量名,参见另一个例子:
void f(const Pc); // void f(char* const) (not const char*)
void g(const int Pc); // void g(const int)
3、[注意:缺省情况下,关键字signed, unsigned, long, 和short声明了int类型,跟在这些说明符后面的类型名应该看作被(重新)声明的变量名字。例如:
void h(unsigned Pc); // void h(unsigned int)
void k(unsigned int Pc); // void k(unsigned int)]