stdio.h
Matthew Seaman
m.seaman at infracaninophile.co.uk
Tue Apr 13 09:40:48 PDT 2004
On Tue, Apr 13, 2004 at 09:45:39AM -0500, Brian Henning wrote:
> I have a question about the stdio.h file.
>
> In the following function signature what does the __P do?
>
> Why is the __P needed?
>
> int (*_close) __P((void *));
History. Backwards compatability. This construct dates from the
times of K&R C, before the ANSI standard that said function prototypes
should contain argument type declarations. If you examine the
<sys/cdefs.h> header file, you'll see that macro is designed to expand
to either an empty pair of brackets -- () -- which is the old-style
prototype, or the string enclosed within it -- (void *) -- which is
the "new" style prototype. I say "new" because prototypes like that
have been standard for more than 10 years.
On any compiler you encounter nowadays that declaration will be
resolved to:
int (*_close) (void *)
meaning _close is a pointer to a function taking an arbitrary pointer
as argument and returning an int.
Yes -- the __P() construct is pretty much obsolete nowadays, but it's
probably more trouble than it's worth to try and strip it out of
everything.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20040413/0695fb99/attachment.bin
More information about the freebsd-questions
mailing list