home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!gatech!concert!sas!mozart.unx.sas.com!sasghm
- From: sasghm@theseus.unx.sas.com (Gary Merrill)
- Subject: Re: Pointer/address reluctance
- Originator: sasghm@theseus.unx.sas.com
- Sender: news@unx.sas.com (Noter of Newsworthy Events)
- Message-ID: <Bt54D0.CFn@unx.sas.com>
- Date: Mon, 17 Aug 1992 18:22:12 GMT
- References: <l8kteaINNp2c@exodus.Eng.Sun.COM> <14807@ksr.com> <mcdonald.206@aries.scs.uiuc.edu>
- Nntp-Posting-Host: theseus.unx.sas.com
- Organization: SAS Institute Inc.
- Lines: 57
-
-
- In article <mcdonald.206@aries.scs.uiuc.edu>, mcdonald@aries.scs.uiuc.edu (J. D. McDonald) writes:
-
- |>
- |> However, in fact pointers **are** addresses of a sort, and the real
- |> programmer nees to understand them if they are to do general programming in
- |> C.
- |>
- |> This can, in fact, be proven:
- |>
- |> 1) General programming includes all the programming that can, and is,
- |> done in C
- |>
- |> 2) Some C programming is for interaction with devices, for example,
- |> direct control of devices from programs and/or device drivers if an OS
- |> uses such beasties.
- |>
- |> 3) Some devices use memory mapped magic addresses
- |>
- |> 4) IF these can be addressed from C, which is usually the case (for example,
- |> C code running in "unhosted" mode at the highest privilege level),
- |> then the usual way to address them is by actually coding the proper bits
- |> into an integral variable (or in rare cases the integral part of a union)
- |> and casing to a pointer.
- |>
- |> QED.
- |>
- |>
- |> Of course, there are some individuals who aren't interested in such
- |> things .. or aren't trusted enough to do it.
- |>
- |> Doug McDonald
-
- If you need to understand them, you need to understand them a little
- better. While there is a (sometimes very) close relationship between
- addresses and pointers in C, they are not the same. Consider, for
- example, the fact that there are some memory models for the 8086
- where a pointer (say a function pointer) is two bytes in size, but
- the address it represents is four bytes in size. The Lattice P
- model had this feature, and our mainframe C compiler implements
- a similar scheme as well. So pointers aren't even necessarily the
- *same size* as addresses.
-
- This brings up the point that there is no requirement for all
- pointers to be the same size. It is not uncommon for function
- pointers to be a different size from data pointers. Does this
- mean or require that the underlying machine supports two different
- kinds of addresses? Hardly.
-
- In addition, of course, as a previous poster pointed out, a pointer
- comes with the additional semantic baggage concerning the size of
- the pointed-to object.
-
- --
- Gary H. Merrill [Principal Systems Developer, C Compiler Development]
- SAS Institute Inc. / SAS Campus Dr. / Cary, NC 27513 / (919) 677-8000
- sasghm@theseus.unx.sas.com ... !mcnc!sas!sasghm
-