DragonFly BSD
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


From: Jeroen Ruigrok/asmodai <asmodai@xxxxxx>
Date: Wed, 28 Jan 2004 07:19:31 +0100

-On [20040127 21:02], Joerg Sonnenberger (joerg@xxxxxxxxxxxxxxxxx) wrote:
>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.

C99:6.7.5.3:10:

"The special case of an unnamed parameter of type void as the only item
in the list specifies that the function has no parameters."

C99:6.7.5.3:14:

"An identifier list declares only the identifiers of the parameters of
the function. An empty list in a function declarator that is part of a
definition of that function specifies that the function has no
parameters. The empty list in a function declarator that is not part of
a definition of that function specifies that no information about the
number or types of the parameters is supplied."

C99:6.11.6:

"The use of function declarators with empty parentheses (not
prototype-format parameter type declarators) is an obsolescent feature.

So, using

void x() { return; }

is obsolete, use

void x(void) { return; }

I have to agree with Matt.

-- 
Jeroen Ruigrok van der Werven <asmodai(at)wxs.nl> / asmodai / kita no mono
PGP fingerprint: 2D92 980E 45FE 2C28 9DB7  9D88 97E6 839B 2EAC 625B
http://www.tendra.org/   | http://diary.in-nomine.org/
Don't try to find the Answer where there ain't no Question here...



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]