很长很长一个在C型?
我知道标题似乎很愚蠢,但我认为这是值得一问。
I know the title seems quite stupid, but I think it's worth asking.
把这个声明(或定义,也许)例如:
Take this declaration(or definition, maybe) for example:
_Thread_local long volatile static int _Atomic const long unsigned x = 10;
我曾经考虑长长
作为一种类型,但如果它是一个类型的名字,怎么能这么多的预选赛插入呢?
I used to consider long long
as a type, but if it's a type name, how can so many qualifiers be inserted into it?
所以我咨询N1570这个问题,只是要更加迷茫。它提到了一些术语,如类型说明符的和类型限定符的,而我无法找到长长
在类型说明符,而不是长长
A原语的C类型?有这么多的书告诉我呢!
So I consulted N1570 with this question, only to be more confused. It mentions some terms such as "type-specifier" and "type-qualifier", and I can't find long long
in "type specifiers", but isn't long long
a primitive type in C? There are so many books telling me so!
的澄清不重复的:的
是的,我看到 交易的存在的问题与长整型长
,但这个问题有什么做的预选赛,并在C
Yes, I saw an existing question deals with long int long
, but this question have something to do with qualifiers, and is in C.
如果你读了标准不够仔细权位,你会发现,在这个问题怪物声明是有效的,即使难以置信。
If you read the right bits of the standard carefully enough, you find that the monster declaration in the question is valid, even if implausible.
正确的位包括:
有五个标准符号整数类型,指定为符号字符
,短
,
INT INT
,长整型
和久长整型
。 (这些和其它类型的可
指定在几个其他方式,如6.7.2所述。)
6.2.5 Types
There are five standard signed integer types, designated as
signed char
,short int
,int
,long int
, andlong long int
. (These and other types may be designated in several additional ways, as described in 6.7.2.)
...
有关每个符号整数类型的,有一个相应的(但不同)的无符号
整数型(与关键字指定无符号
),使用相同数量的
存储(包括符号信息)并具有相同的对齐要求。
For each of the signed integer types, there is a corresponding (but different) unsigned
integer type (designated with the keyword unsigned
) that uses the same amount of
storage (including sign information) and has the same alignment requirements.
至少有一个类型说明符应在每个声明的声明说明符给出,
并在每个结构声明和类型名称说明符限定符列表。的每个列表
类型说明符应为以下多集之一(以逗号分隔,当有
每件超过一个多集);可发生于任何订单的类型说明符,可能
混合与其他声明说明符。
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 multisets (delimited by commas, when there is more than one multiset per item); the type specifiers may occur in any order, possibly intermixed with the other declaration specifiers.
...
-
长长
,符号long long
,得到long long int
或
签订了长整型
-
无符号长长
或无符号长long int类型
-
long long
,signed long long
,long long int
, orsigned long long int
-
unsigned long long
, orunsigned long long int
其他的声明说明符包括存储类(静态
和 _Thread_local
中的例子),然后键入预选赛(挥发性
和 _Atomic
)。
Other declaration specifiers include storage classes (static
and _Thread_local
in the example), and type qualifiers (volatile
and _Atomic
).
6.7声明
语法
的声明:的结果
      声明-符初始化说明符-listopt; 的结果
     的 static_assert声明的
的声明-符:的结果
     的存储类说明符结果
     报关,符选择结果
     类型说明符声明 - 符选择结果
     类型限定符声明 - 符选择结果
     函数说明符的声明 - 符选择结果
     对齐说明符声明 - 符选择的
declaration-specifiers:
storage-class-specifier
declaration-specifiersopt
type-specifier declaration-specifiersopt
type-qualifier declaration-specifiersopt
function-specifier declaration-specifiersopt
alignment-specifier declaration-specifiersopt
另外,由著名奥拉夫在comment:
存储类说明中比在声明的开头其他的放置
在声明符是一个过时的功能。
6.11.5 Storage-class specifiers
The placement of a storage-class specifier other than at the beginning of the declaration specifiers in a declaration is an obsolescent feature.
这也是古怪的分裂整数类型的关键字(类型说明符)。申报的更正统的版本将是:
It is also eccentric to split up the integer type keywords (the type specifier). A more orthodox version of the declaration would be:
static _Thread_local _Atomic const volatile unsigned long long int x = 10;
(也可能掉落 INT
)。