home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12473 < prev    next >
Encoding:
Text File  |  1992-08-17  |  2.1 KB  |  37 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!munnari.oz.au!metro!mama!greyham
  3. From: greyham@research.canon.oz.au (Graham Stoney)
  4. Subject: Re: I wish ANSI-C sizeof (void) == 1 (was Re: preprocessing subterfuge)
  5. Message-ID: <Bt5n8A.41B@research.canon.oz.au>
  6. Sender: news@research.canon.oz.au
  7. Organization: Canon Information Systems Research Australia
  8. 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>
  9. Date: Tue, 18 Aug 1992 01:09:45 GMT
  10. Lines: 25
  11.  
  12. volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) writes:
  13. >In article <BswME5.6Mp@research.canon.oz.au>, greyham@research.canon.oz.au (Graham Stoney) writes:
  14. >|>                   void * is the natural type to use when you're considering a
  15. >|> pointer to a chunk of memory that can hold any arbitrary type; in the Unix
  16. >|> kernel for instance it seems a natural replacement for caddr_t. And any time
  17. >|> I need to do arithmetic on one, it's always in terms of bytes - it would be
  18. >   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  19. >If you need to do arithmetic on one, then the variable should not be declared
  20. >as "void *" in the first place. That type is for pointing to objects whose
  21. >size you don't know. If you know you're going to be dealing with arrays of
  22. >bytes, then declare it as "[unsigned] char *". 
  23.  
  24. Yes, but I'm _not_ dealing with arrays of bytes. I'm pointing to arbitrary
  25. locations which store as yet unknown types. One example is converting a
  26. pointer in shared memory from one virtual address space to another. Another
  27. is adding the base address of a hardware device to the address at which the
  28. block of address space in which it resides is mapped. You really aren't
  29. dealing with arrays of bytes, just memory addresses; you can't dereference
  30. them, but sometimes you need to add to them.
  31.  
  32. Graham
  33. -- 
  34. Graham Stoney                    | "a Perl script is correct if it's halfway
  35. Flip Dibner fan club, "Hi Flip!" |  readable and gets the job done before your
  36. Ph: +61 2 805-2909  Fax: -2929   |  boss fires you." L. Wall & R. Schwartz
  37.