www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/10/10/18:02:25

Date: Mon, 10 Oct 94 17:22:02 GMT
From: dolan AT fnoc DOT navy DOT mil (Kent Dolan)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: size of int == size of pointer ???

> From: "Frederick W. Reimer" <fwreimer AT crl DOT com>

> As far as Unix programs and such are concerned, what's wrong with
> assuming that the size of an int is the same as the size of a
> pointer?

Mostly, that you'll get burned very frequently.

It is not even guaranteed that an integer and a pointer are the same
_kind_ of entities.  In some C implementations, pointers are
structures!  (The old Multics OS C, for one, used a structure roughly
equivalent to the Intel Segment:Offset mechanism. Tagged architectures
also use hardware mechanisms to distinguish pointers from other kinds
of data.)

The only portability-safe way to use pointers is to treat them as
opaque data types.  This is why C provides overloaded +, -, ++, and --
operators for pointers that behave quite differently than do the same
operators applied to integers.

Since many participants on this mailing list tout use of djgpp as a way
to assist in making code portable among many other different
platforms/OSs also portable to MS-DOS, pretending that there is some
given relationship between pointers and one or another type of integer
is a recipe for disaster if the code needs to be portable.

In addition, we are now in a transition period from 32 significant bits
in pointers to longer pointers, like the earlier transition from a
mixed bag of 16, 20, and 24 significant bits in pointers to 32
significant bits in pointers.  There is at least one platform currently
using 40 significant bits in pointers, and several using 64 significant
bits in pointers.

This transition is occurring because a gigabyte of memory is no longer
looking like an unattainable goal, but is instead looking like an
unacceptable constraint, in high end processors.  History shows that
the same capabilities and corresponding problems will rapidly become
evident on mass market computers, possibly in five years or less.

Xanthian.
--
Kent, the man from xanth.
Kent Paul Dolan, CSC contractor at Fleet Numerical.  (408) 656-4363.
(Navy Unix email:   )  (Navy cc:Mail email: )  (real world email:     )
<dolan AT fnoc DOT navy DOT mil>  <dolank AT fnoc DOT navy DOT mil>  <xanthian AT well DOT sf DOT ca DOT us>

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019