Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

c - Which section in C89 standard allows the "implicit int" rule?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...