这部分C89标准允许"隐式int"规则? [英] Which section in C89 standard allows the "implicit int" rule?

查看:341
本文介绍了这部分C89标准允许"隐式int"规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 GCC 中,code:

 注册= 3;
静态B = 3;

这是在使用 -std = C89 -pedantic-错误标记允许的,虽然有一个警告。

然而,它接收与 -std = C99 -pedantic-错误标记错误。

我不知道哪的C89标准部分允许隐式int类型的规则?


解决方案

这是允许的部分的隐式int 的C89中的规则将部分 3.5.2 类型说明符的它说(的重点煤矿的):


  

INT,签名,INT,或没有类型说明符


基思·汤普森在C90的评论指出,部分 6.5.2 并说,的唯一的区别是由ISO需要一些介绍材料,从而在部分的重新编号

C99 这哪里改变,该节 6.7.2 类型说明符的和它说:


  

INT,签名,或签署INT


这也包括在文件 N661:禁止在声明中隐含的INT它说:


  

变化6.5.2类型说明符;添加新的句子
          开始约束第一段:
                  至少有一个类型说明符应给予
                  该声明说明符的声明。

 更改6.5.2类型说明符,约束,自:
             - 诠释,签名,int或没有类型
               符
    至:
             - 诠释,签名,或签署INT


While using gcc, the code:

register a = 3;
static b = 3;

it is allowed while using the -std=c89 -pedantic-errors flags, although there is a warning.

However it receive an error with the -std=c99 -pedantic-errors flags.

I wonder which section of the C89 standards allows the "implicit int" rule?

解决方案

The section that allowed the implicit int rule in C89 would be section 3.5.2 Type specifiers which says (emphasis mine):

int , signed , signed int , or 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.

In C99 where this changed, the section is 6.7.2 Type specifiers and it says:

int, signed, or signed int

This is also covered in document N661: Disallow implicit "int" in declarations which says:

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.

    Change in 6.5.2 Type specifiers, Constraints, from:
            -- int, signed, signed int, or no type
               specifiers
    to:
            -- int, signed, or signed int

这篇关于这部分C89标准允许"隐式int"规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆