I’m reading about Typedef on wikipedia. Example mentioned on that page is
typedef int km_per_hour ;
typedef int points ;
km_per_hour current_speed ;
points high_score ;
...
void congratulate(points your_score) {
if (your_score > high_score)
...
Going further it says this which I’m not able to understand why?
void foo() {
unsigned int a; // Okay
unsigned km_per_hour b; // Compiler complains
long int c; // Okay
long km_per_hour d; // Compiler complains
...
Why does the compiler complain for unsigned and long?
You cannot prepend
signedorunsignedbefore atypedef‘d type.signedandunsignedcan only modify basic integer types and do that directly.The compiler parses
signedorunsignedeither alone or nearchar,short,intandlong. In all other cases they are considered invalid/unexpected/misplaced.In that sense,
signedandunsigneddon’t work asconstorvolatilemodifiers.