Próbowałem następujący kodCzy typedef jest specyfikatorem klasy pamięci?
#include <stdio.h>
int main(void)
{
typedef static int sint;
sint i = 10;
return 0;
}
i hit następujący błąd:
error: multiple storage classes in declaration specifiers
Kiedy przekazał specyfikację C99, poznałem, że typedef
jest 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;
Jedynym wyjaśnieniem, że udało mi się znaleźć (w oparciu o niektóre przeszukiwanie internetu i krzyż odnosząc różne sekcje w specyfikacji C99) był syntactic convenience only to make the grammar simpler
.
Szukam uzasadnienia/wyjaśnienia, w jaki sposób nazwa typu może mieć specyfikator klasy pamięci?
Czy nie ma sensu posiadanie kodu takiego jak typedef static int sint;
?
lub Gdzie się mylę ?!
patrz: http://stackoverflow.com/questions/2218435/why-typedef-can-not-be-used-with-static – Demi