Date: Tue, 13 Apr 2004 17:40:41 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Brian Henning <b1henning@hotmail.com> Cc: freebsd-questions@freebsd.org Subject: Re: stdio.h Message-ID: <20040413164041.GB94448@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <BAY15-DAV48beUzmRf6000210b2@hotmail.com> References: <BAY15-DAV48beUzmRf6000210b2@hotmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
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
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)
iD8DBQFAfBgJdtESqEQa7a0RAkrZAJ0Z7c5IIY78ofF7u4Bqm7iynkcD2gCfUes1
ApZtrsWa6yFlQymwJsOSHnM=
=OLM4
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040413164041.GB94448>
