Re: Why not auto?
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 17 May 2005 04:29:10 GMT
Ben Pfaff <blp@xxxxxxxxxxxxxxx> writes:
> Keith Thompson <kst-u@xxxxxxx> writes:
>
>> Apart from EXIT_SUCCESS being undeclared (it's in <stdlib.h>, not
>> <stdio.h>), I'm not sure. I had thought that C89/C90 allows implicit
>> int only for functions, not for objects, but I might be mistaken. (I
>> just took a quick look through the C90 standard and didn't find
>> anything definitive.)
>>
>> I'm sure someone here can provide the appropriate chapter and verse.
>
> It's hard to provide exact C&V that prohibits something that's
> not prohibited. My C standard notes say the following:
>
> In C90, a declaration without a type specifier had `int'
> supplied by default, called "implicit `int'" (C89 6.5.2#3).
> C99 disallows this practice, requiring that a type specifier
> be explicitly supplied (C99 6.7.2#2).
It's not just not prohibited; there's an explicit rule that says that
a declaration with no type specifier is implicitly of type int. I
missed it because it's fairly well hidden in C90 6.5.2:
Constraints
Each list of type specifiers shall be one of the following sets
(delimited by commas, when there is more than one set on a line);
the type specifiers may occur in any order, possibly intermixed
with the other declaration specifiers.
-- void
-- char
[snip]
-- int, signed, signed int, or no type specifiers
[snip]
Semantics
[snip]
Each of the above comma-separated sets designates the same type,
except that for bit-fields, the type signed int (or signed) may
differ from int (or no type specifiers).
So it looks like I was correct to think that I might be mistaken.
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: Why not auto?
- From: Ben Pfaff
- Re: Why not auto?
- References:
- Re: Why not auto?
- From: Mike Wahler
- Re: Why not auto?
- From: Clark S . Cox III
- Re: Why not auto?
- From: Ben Pfaff
- Re: Why not auto?
- From: Michael Wojcik
- Re: Why not auto?
- From: Keith Thompson
- Re: Why not auto?
- From: Ben Pfaff
- Re: Why not auto?
- Prev by Date: Re: Semaphore Error - Storage size of arg
- Next by Date: Re: Why not auto?
- Previous by thread: Re: Why not auto?
- Next by thread: Re: Why not auto?
- Index(es):
Relevant Pages
|