我尝试了以下代码
#include <stdio.h>
int main(void)
{
typedef static int sint;
sint i = 10;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
并遇到以下错误:
error: multiple storage classes in declaration specifiers
Run Code Online (Sandbox Code Playgroud)
当我提到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;
Run Code Online (Sandbox Code Playgroud)
我能找到的唯一解释(基于一些互联网搜索和交叉引用C99规范中的各个部分)是syntactic convenience only to make the grammar simpler. …