Date: Sun, 4 Jun 2000 11:19:17 -0400 (EDT) From: Brian Fundakowski Feldman <green@FreeBSD.org> To: Bruce Evans <bde@zeta.org.au> Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/sys mbuf.h Message-ID: <Pine.BSF.4.21.0006041045370.543-100000@green.dyndns.org> In-Reply-To: <Pine.BSF.4.21.0006040228200.9813-100000@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 4 Jun 2000, Bruce Evans wrote:
> I don't know how you learned that from me. I've always said that caddr_t
> should have started going away around 1980 when K&R compilers started
> supporting void *.
>
> Bruce
Okay, let me see if I interpret your sparse explanation correctly =)
The caddr_t type was created decades ago to represent a generic "core
address". It was originally defined to be equivalent to a pointer to a
char, as there was no type available which was more correct; caddr_t
became the pseudo- more correct type. Over the years, as more compilers
started supporting a pointer to a void, caddr_t was increasingly used so
that the proper type would be a type definition away.
With caddr_t, old compilers could get the very moldy "everything can
be represented as a pointer to a char", and the new ones would get the
standardized:
[#1] A pointer to void may be converted to or from a pointer
to any incomplete or object type. A pointer to any
incomplete or object type may be converted to a pointer to
void and back again; the result shall compare equal to the
original pointer.
Therefore, caddr_t is a historical relic which, in its time, was
but a placeholder which made it easy to wait for proper implementation
of the feature desired. It was always improper as a pointer to a char,
as the char * type was never guaranteed to be large enough to cast to
or from any other pointer type. However, char * was all that existed
in all compilers.
The void * type was created to duplicate what was wanted in a
generic address type (such as arithmetical semantics), while correctly
demonstrating that the type contained was an "unknown". The caddr_t type
should be phased out now since only an infinitesimal amount of compilers
can't support void *, and the void * type itself gives better type
checking then the caddr_t type definition. In all cases, void * is to
be used instead of caddr_t in new code.
How's my interpretation? Be gentle, because I don't have any actual
knowledge to go on ;)
--
Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! /
green@FreeBSD.org `------------------------------'
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0006041045370.543-100000>
