home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe
- From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe)
- Newsgroups: comp.lang.c
- Subject: Re: I wish ANSI-C sizeof (void) == 1 (was Re: preprocessing subterfuge)
- Message-ID: <1992Aug14.195132.16700@crd.ge.com>
- Date: 14 Aug 92 19:51:32 GMT
- References: <1992Aug9.144525.4521@taumet.com> <23277A@erik.naggum.no> <1992Aug10.031337.4424@druid.uucp> <1992Aug11.202135.28878@ugle.unit.no> <BswME5.6Mp@research.canon.oz.au>
- Sender: volpe@bart (Christopher R Volpe)
- Reply-To: volpe@ausable.crd.ge.com
- Organization: GE Corporate Research & Development
- Lines: 34
- Nntp-Posting-Host: bart.crd.ge.com
-
- In article <BswME5.6Mp@research.canon.oz.au>, greyham@research.canon.oz.au (Graham Stoney) writes:
- |> toriver@flipper.pvv.unit.no (Tor Iver Wilhelmsen) writes:
- |>
- |> When I first heard of GNU C's deviation from the standard with the sizeof type
- |> 'void', I thought it was a bad idea; but now I hope ANSI will standardise it
- |> next time around. void * is the natural type to use when you're considering a
- |> pointer to a chunk of memory that can hold any arbitrary type; in the Unix
- |> kernel for instance it seems a natural replacement for caddr_t. And any time
- |> I need to do arithmetic on one, it's always in terms of bytes - it would be
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- If you need to do arithmetic on one, then the variable should not be declared
- as "void *" in the first place. That type is for pointing to objects whose
- size you don't know. If you know you're going to be dealing with arrays of
- bytes, then declare it as "[unsigned] char *".
-
- -Chris
-
- |> great to be able to not have to cast to char * every time you need to do
- |> arithmetic on one, which seems to happen quite a lot in stuff like device
- |> drivers.
- |>
- |> Any comments?
- |>
- |> Graham
- |> --
- |> Graham Stoney | "a Perl script is correct if it's halfway
- |> Flip Dibner fan club, "Hi Flip!" | readable and gets the job done before your
- |> Ph: +61 2 805-2909 Fax: -2929 | boss fires you." L. Wall & R. Schwartz
-
- --
- ==================
- Chris Volpe
- G.E. Corporate R&D
- volpecr@crd.ge.com
-