home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!munnari.oz.au!metro!mama!greyham
- From: greyham@research.canon.oz.au (Graham Stoney)
- Subject: Re: I wish ANSI-C sizeof (void) == 1 (was Re: preprocessing subterfuge)
- Message-ID: <Bt5n8A.41B@research.canon.oz.au>
- Sender: news@research.canon.oz.au
- Organization: Canon Information Systems Research Australia
- 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> <1992Aug14.195132.16700@crd.ge.com>
- Date: Tue, 18 Aug 1992 01:09:45 GMT
- Lines: 25
-
- volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
- >In article <BswME5.6Mp@research.canon.oz.au>, greyham@research.canon.oz.au (Graham Stoney) writes:
- >|> 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 *".
-
- Yes, but I'm _not_ dealing with arrays of bytes. I'm pointing to arbitrary
- locations which store as yet unknown types. One example is converting a
- pointer in shared memory from one virtual address space to another. Another
- is adding the base address of a hardware device to the address at which the
- block of address space in which it resides is mapped. You really aren't
- dealing with arrays of bytes, just memory addresses; you can't dereference
- them, but sometimes you need to add to them.
-
- 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
-