我尝试下面的代码是typedef一个存储类说明符?
#include <stdio.h>
int main(void)
{
typedef static int sint;
sint i = 10;
return 0;
}
,并击中了以下错误:
error: multiple storage classes in declaration specifiers
当我提到的C99规范,我才知道,typedef
是storage class
。
6.7.1 Storage-class specifiers
Syntax
storage-class-specifier:
typedef
extern
static
auto
register
Constraints: At most, one storage-class specifier may be
given in the declaration specifiers in a declaration
Semantics: The typedef specifier is called a ‘‘storage-class specifier’’
for syntactic convenience only;
,我能找到的唯一解释(基于C99规范一些互联网搜索与交叉参考各个部分)为syntactic convenience only to make the grammar simpler
。
我正在寻找一些理由/解释如何可以类型名称存储类说明符?
像typedef static int sint;
这样的代码没有意义吗?
或我在哪里出错?
见:http://stackoverflow.com/questions/2218435/why-typedef-can-not-be-used-with-static – Demi 2011-12-30 01:15:06