Why is this code invalid?
typedef int INT;
unsigned INT a=6;
whereas the following code is valid
typedef int INT;
static INT a=1;
?
As per my understanding unsigned int is not a "simple type specifier" and so the code is ill-formed. I am not sure though.
Can anyone point to the relevant section of the Standard which makes the first code invalid(and the second code valid)?
EDIT
Although Johannes Schaub’s answer seemed to be correct and to the point(he had deleted his answer BTW) I accepted James Curran’s answer for its correctness and preciseness.
typedefs are not like macros. They are not just text substitution. A Typedef creates a new typename.Now when you say
unsigned int, theunsignedisn’t a modifier which is tacked onto theint.unsigned intis the complete typename; it just happens to have a space in it.So, when you say
typedef int INT;thenINTis the complete typename. It can’t be modified.static(likeconst) is a storage class specifier. It’s not actually part of the type name.