DragonFly submit List (threaded) for 2004-01
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
Re: patch to un-K&R-ify libkern
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
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]