I tried the following code
#include <stdio.h>
int main(void)
{
typedef static int sint;
sint i = 10;
return 0;
}
and hit the following error:
error: multiple storage classes in declaration specifiers
When I referred the C99 specification, I came to know that typedef
is a 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;
The only explanation that I could find (based on some internet search and cross referring various sections in C99 specification) was syntactic convenience only to make the grammar simpler
.
I'm looking for some justification/explanation on how can a type name have storage class specifier?
Doesn't it make sense to have a code like typedef static int sint;
?
or Where am I going wrong?!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…