【问题标题】:Which section in C89 standard allows the "implicit int" rule?C89 标准中的哪个部分允许“隐式 int”规则?
【发布时间】:2014-12-16 18:49:28
【问题描述】:

使用gcc时,代码:

register a = 3;
static b = 3;

在使用-std=c89 -pedantic-errors 标志时是允许的,尽管有警告。

但是,它收到带有 -std=c99 -pedantic-errors 标志的错误。

我想知道 C89 标准的哪个部分允许“隐式 int”规则?

【问题讨论】:

    标签: c standards language-lawyer c89 implicit-int


    【解决方案1】:

    在 C89 中允许 implicit int 规则的部分是 3.5.2 Type specifiers 部分,它表示(emphasis mine):

    int , signed , signed int , 或没有类型说明符

    cmets 中的 Keith Thompson 指出,在 C90 中,该部分是 6.5.2,并说,唯一的区别是 ISO 要求的一些介绍性材料,导致这些部分重新编号。 p>

    C99 中更改的部分是 6.7.2 类型说明符,它说:

    int、signed 或signed int

    这也包含在文件 N661: Disallow implicit "int" in declarations 中,其中说:

    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
    

    【讨论】:

    • 1989 ANSI C 标准中的第 3.5.2 节是 1990 ISO C 标准中的第 6.5.2 节。 (这两个标准描述的语言完全相同。唯一的区别是 ISO 要求的一些介绍性材料,因此对部分进行了重新编号。)
    • @KeithThompson 谢谢,我想知道提案中的那个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 2013-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多