This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: K&R style prototypes
- To: Jimen Ching <jching at flex dot com>
- Subject: Re: K&R style prototypes
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Wed, 08 Apr 1998 16:44:11 -0700
- cc: egcs-bugs at cygnus dot com
I don't have the standard, so could
someone quote the passage that specifically allows the K&R style function
declaration?
In the '89 standard, that would be Section 3.7.1 Function Definitions, which
defines function definition syntax such that both the K&R style and
prototype-style declarations are valid.
In Section 3.9 Future Language directions, it says that K&R style declarations
and definitions are an obsolescent feature. They are however valid features,
which means an ANSI C compiler are required to accept them.
Neither of these is what I was looking for. I'm looking for a warning or
error message that says: "K&R style prototype used with -ansi".
That is basically what -Wstrict-prototypes does, though it isn't dependent
on -ansi. Why doesn't it do what you want?
Btw, I'm curious. What is the benefit of the warnings above? Who cares
if there's no previous prototype for 'func'? Since I call the function
after it is defined, what would be the point of prototyping it?
If you prototype all extern functions in an appropriate .h file, then if
we see a function definition and don't have a prototype for it in scope then
your .h file is buggy, and you would want to know about it.
Jim