【发布时间】:2012-01-30 05:56:51
【问题描述】:
我尝试了以下代码
#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;
我能找到的唯一解释是syntactic convenience only to make the grammar simpler。
我正在寻找一些关于类型名称如何具有存储类说明符的理由/解释?
像typedef static int sint; 这样的代码难道没有意义吗?
或者我哪里错了?!
【问题讨论】: