“长期无符号”在C中是否与“unsigned long”一样有效?

最近有一个问题是关于ULLLLU是否有效用于指定C中的无符号长long常量。我知道它们都是有效的但我认为ULL会更好,因为它匹配unsigned long long类型。

但是,我现在不太确定。 gcc编译器允许以下内容无怨言:

 int main(void) { unsigned int a = 1; int unsigned b = 2; return 0; } 

所以我的问题是: int unsigned ,还有其他变体,比如标准的long long unsigned有效类型?

ISO C11标准在6.2.5 Types

有五种标准的有符号整数类型,指定为signed char,short int,int,long int和long long int。

对于每个有符号整数类型,存在相应(但不同)的无符号整数类型(使用关键字unsigned指定),其使用相同数量的存储(包括符号信息)并具有相同的对齐要求。

但是,在该部分中没有关于基本类型和unsigned修饰符出现的顺序的任务。

控制部分稍后在标准中, 6.7.2 Type specifiers ,在此解释:

类型说明符是voidcharshortintlongfloatdoublesignedunsigned_Bool_Complex

每个声明中的声明说明符中应至少给出一个类型说明符,并在每个结构声明和类型名称的说明符限定符列表中给出。 每个类型说明符列表应为以下多个集合之一(用逗号分隔,每个项目有多个多集); 类型说明符可以按任何顺序出现,可能与其他声明说明符混合。

然后继续列出所有多重集,例如unsigned long, or unsigned long int

但是重要的短语是the type specifiers may occur in any order ,这意味着所有这些对于该multiset都有效:

 unsigned long long unsigned unsigned long int unsigned int long long unsigned int long int unsigned int unsigned long int long unsigned 

说明符的顺序无关紧要。

 unsigned long long is the same as long long unsigned. 

两种类型均符合C标准(c99)。