From ripley at stats.ox.ac.uk  Mon Jan 28 10:03:31 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 28 Jan 2008 09:03:31 +0000 (GMT)
Subject: [Rd] Strict-prototypes definitions in R includes
In-Reply-To: <27d1e6020801280057i5216caefifab3a516a633b640@mail.gmail.com>
References: <27d1e6020801270649y16e65f13o8bc400591aceb2f2@mail.gmail.com>
	<alpine.LFD.1.00.0801272145030.3059@gannet.stats.ox.ac.uk>
	<27d1e6020801280057i5216caefifab3a516a633b640@mail.gmail.com>
Message-ID: <alpine.LFD.1.00.0801280858270.9931@gannet.stats.ox.ac.uk>

On Mon, 28 Jan 2008, Laurent Gautier wrote:

> Thanks the answer.
>
> Would submitted patches with strict post-K&R prototypes definition,
> for the "void" cases and for the includes likely to be used by writers of
> R extensions, be accepted ?

Yes, against R-devel.

But some you won't be able to do (e.g. in GraphicsDevice.h, DL_FUNC in 
Rdynload.h), and I am not sure that there are many others in the public 
include files.

>
>
> Laurent
>
>
>
>
> 2008/1/27, Prof Brian Ripley <ripley at stats.ox.ac.uk>:
>> I think the answer is 'it depends'.
>>
>> - such prototypes are not required by C99.
>> - using (void) is part of some authors' style and not of others. For the
>>    latter, this is not an 'oversight' but an uglification.
>> - in some cases the omission is deliberate as the function is used for
>>    variable sets of arguments (e.g, in GraphicsDevice.h).
>> - in others the omission is because it seemed safer to leave the
>>    prototype out than to get it wrong (when passing functions, for
>>    example).
>> - some code is taken from other projects and still has K&R style
>>    declarations.
>>
>> On Sun, 27 Jan 2008, Laurent Gautier wrote:
>>
>>>  Dear list,
>>>
>>>  Whenever the flag "-Wstrict-prototypes" is set in gcc, compiling code that
>>> includes headers in lib/R/include generates often warnings
>>> (example with R-2.6.1:
>>> Rinternals.h:560: warning: function declaration isn't a prototype
>>> ).
>>>
>>>  All such warnings I looked at were about functions with empty
>>> signatures declared
>>> as "bar foo();" rather than "bar foo(void);". Is there a reason, or is
>>> this just an oversight in the include files ?
>>
>> It seems you were rather selective in your looking.
>>
>>>
>>>  Thanks,
>>>
>>>
>>> Laurent
>>
>> --
>> Brian D. Ripley,                  ripley at stats.ox.ac.uk
>> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
>> University of Oxford,             Tel:  +44 1865 272861 (self)
>> 1 South Parks Road,                     +44 1865 272866 (PA)
>> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Strict-prototypes definitions in R includes
Prof Brian Ripley