patch to un-K&R-ify libkern
Joerg Sonnenberger
joerg at britannica.bec.de
Tue Jan 27 11:51:44 PST 2004
On Tue, Jan 27, 2004 at 02:24:54PM -0500, Dave Cuthbert wrote:
> Actually, I'm somewhat surprised that compilers accept an ANSI prototype
> followed by a K&R function definition; but both gcc 3.3 and SunPro C
> accept:
>
> void x(void);
> void x() { return; }
If you read the ISO C99 specification (or an earlier one), you will
find that this is correct. Even for K&R style void x() {} is a function
without arguments. This is even the only correct form.
>
> Both also issue a diagnostic (gcc error, SunPro warning) about:
>
> void x(int);
> void x() { return; }
This is simply invalid ;-) SunPro is broken or at least not a conforming
compiler for accepting this code.
> Learn something new every day. At any rate, I stick to the ANSI style
> for my new code.
I wasn't 100% sure about this earlier, but after having digged it up,
I feel pretty confident now. So we all learned something ;-)
Joerg
> Dave
More information about the Submit
mailing list