问题描述
在N3797 7.1.1 / 3中有以下注释:
注意:由于默认情况下是signed,unsigned,long和short隐含int,一个类型名称出现在这些说明符之一后面被视为(重新)声明的名称。
一张纸条。在标准中有一个地方使规范性声明具有相同的效果吗?
是符合标准的C和C ++使用签名 ,无符号,长和短不包含 int
或者,为了将它放在代码中,符合以下标准,如果是这样,它在哪里说?
签署a;无符号b
short c;
long d;
signed f(signed p,unsigned q,short r,long s);
unsigned * f(signed * p,unsigned * q,short * r,long * s);
[我不知道是否推荐或首选,因为害怕得到基于意见的答案。
我知道这一直是这样,但我们至少可以回到最早公开的草案标准。对于C ++,将和 7.1.5.2
简单类型说明符 表7
包含以下条目:
无符号的unsigned int
signedint
longlong int
shortshort int
我们可以返回部分 6.7.2
类型说明说: ...]
类型说明符的每个列表应该是以下集合之一(当
多于一行时,以逗号分隔); [...]
并包括以下项目符号:
因此,所有所有符合标准的类型说明符和两个引号都来自相应标准草案的规范部分。
In N3797 7.1.1/3 there is the following note:
Note: Since signed, unsigned, long, and short by default imply int, a type-name appearing after one of those specifiers is treated as the name being (re)declared.
But this is only a note. Is there somewhere in the standard that makes a normative statement to the same effect?
Is is proper standards-compliant C and C++ to use signed, unsigned, long and short without int in each and every situation?
Or, to put it in code, are the following standards-compliant and if so where does it say so?
signed a;
unsigned b;
short c;
long d;
signed f(signed p, unsigned q, short r, long s);
unsigned* f(signed* p, unsigned* q, short* r, long* s);
[I hesitate to ask whether it's recommended or preferred, for fear of getting opinion-based answers.]
As far I know it has always been that way but we can at least go back to the earliest publicly available draft standards. For C++ would be 1804 and in section 7.1.5.2
Simple type specifiers Table 7
simple-type-specifiers and the types they specify includes the following entries:
unsigned "unsigned int"
signed "int"
long "long int"
short "short int"
for C we can go back to C99 which in section 6.7.2
Type specifiers says:
and includes the following bullets:
So these all all standards compliant type specifiers and both quotes come from the normative section of the respective draft standards.
这篇关于在所有版本的C和C ++中,有签名,无符号,长整型和短整型的所有有效类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!