While using gcc
, the code:
使用gcc时,代码:
register a = 3;
static b = 3;
it is allowed while using the -std=c89 -pedantic-errors
flags, although there is a warning.
虽然有警告,但在使用-std = c89 -pedantic-errors标志时允许使用它。
However it receive an error with the -std=c99 -pedantic-errors
flags.
但是,它会收到-std = c99 -pedantic-errors标志的错误。
I wonder which section of the C89 standards allows the "implicit int" rule?
我想知道C89标准的哪一部分允许“隐含整数”规则?
1 个解决方案
#1
14
The section that allowed the implicit int rule in C89 would be section 3.5.2
Type specifiers which says (emphasis mine):
在C89中允许隐式int规则的部分将是3.5.2类型说明符,它表示(强调我的):
int , signed , signed int , or no type specifiers
int,signed,signed int或no type specifiers
Keith Thompson in the comments points out that in C90 the section is 6.5.2
and says, The only difference is some introductory material required by ISO, resulting in a renumbering of the sections.
Keith Thompson在评论中指出,在C90中该部分是6.5.2并且说,唯一的区别是ISO要求的一些介绍性材料,导致部分重新编号。
In C99 where this changed, the section is 6.7.2
Type specifiers and it says:
在C99中,这改变了,该部分是6.7.2类型说明符,它说:
int, signed, or signed int
int,signed或signed int
This is also covered in document N661: Disallow implicit "int" in declarations which says:
这也包含在文档N661中:在声明中禁止隐式“int”,其中说:
Change in 6.5.2 Type specifiers; add new sentence at beginning of first paragraph of Constraints: At least one type specifier shall be given in the declaration specifiers in a declaration.
6.5.2类型说明符的变化;在约束的第一段开头添加新句子:在声明中的声明说明符中至少应给出一个类型说明符。
Change in 6.5.2 Type specifiers, Constraints, from: -- int, signed, signed int, or no type specifiers to: -- int, signed, or signed int
#1
14
The section that allowed the implicit int rule in C89 would be section 3.5.2
Type specifiers which says (emphasis mine):
在C89中允许隐式int规则的部分将是3.5.2类型说明符,它表示(强调我的):
int , signed , signed int , or no type specifiers
int,signed,signed int或no type specifiers
Keith Thompson in the comments points out that in C90 the section is 6.5.2
and says, The only difference is some introductory material required by ISO, resulting in a renumbering of the sections.
Keith Thompson在评论中指出,在C90中该部分是6.5.2并且说,唯一的区别是ISO要求的一些介绍性材料,导致部分重新编号。
In C99 where this changed, the section is 6.7.2
Type specifiers and it says:
在C99中,这改变了,该部分是6.7.2类型说明符,它说:
int, signed, or signed int
int,signed或signed int
This is also covered in document N661: Disallow implicit "int" in declarations which says:
这也包含在文档N661中:在声明中禁止隐式“int”,其中说:
Change in 6.5.2 Type specifiers; add new sentence at beginning of first paragraph of Constraints: At least one type specifier shall be given in the declaration specifiers in a declaration.
6.5.2类型说明符的变化;在约束的第一段开头添加新句子:在声明中的声明说明符中至少应给出一个类型说明符。
Change in 6.5.2 Type specifiers, Constraints, from: -- int, signed, signed int, or no type specifiers to: -- int, signed, or signed int