Typ unsigned
-
Hallo,
ich habe gerade diesen Code gesehen:
unsigned sws[3];Ist das jetzt ein Array von unsigned long oder unsigned short oder unsigned int oder... ??
-
unsigned = unsigned int
edit: Du wirfst da allerdings ein interessantes Problem auf: Auch wenn die obige Antwort auf alle Compiler zutrifft die ich kenne, so kann ich doch keine Stelle im Standard finden, die dieses Verhalten rechtfertigt. Ich kann auch nirgends finden, dass man
long int
(so heißt das nämlich eigentlich) zulong
abkürzen darf. Findet jemand die Stelle im Standard oder ist das tatsächlich nur ein (weit verbreitetes) Compilerfeature?
-
Abschnitt 6.7.2 im C99-Draft n869 sagt das ganz explizit.
At least one type specifier shall be given in the declaration specifiers in each declaration,
and in the specifier-qualifier list in each struct declaration and type name. Each list of
type specifiers shall be one of the following sets (delimited by commas, when there is
more than one set on a line); the type specifiers may occur in any order, possibly
intermixed with the other declaration specifiers.
— void
— char
— signed char
— unsigned char
— short, signed short, short int, or signed short int
— unsigned short, or unsigned short int
— int, signed, or signed int
— unsigned, or unsigned int
— long, signed long, long int, or signed long int
— unsigned long, or unsigned long int
— long long, signed long long, long long int, or signed long
long int
— unsigned long long, or unsigned long long int
— float
— double
— long double
— _Bool
— float _Complex
— double _Complex
— long double _Complex
— float _Imaginary
— double _Imaginary
— long double _Imaginary
— struct or union specifier
— enum specifier
— typedef name
[...]
Each of the comma-separated sets designates the same type, except that for bit-fields, it is
implementation-defined whether the specifier int designates the same type as signed
int or the same type as unsigned int.