pointer sizes, was: Re: What does char **ch mean?

Richard Harter rh at smds.UUCP
Thu May 16 16:33:51 AEST 1991


In article <wolfram.674309645 at akela>, wolfram at akela.informatik.rwth-aachen.de (Wolfram Roesler) writes:

> >>that the declaration char **ch; is equivalent to char *ch;
> >No, they're not at all equivalent.  They might not even have the same size.

> I advised somebody something similar to that, telling him (like I learned
> from the FAQ) that weird machines have weird pointers, that (char*)0 and
> 0L might have different binary representations and the like. His response
> to this was:
> 	"I claim there are no machines like this"
> What do you gurus say about this? How about an example of a machine or OS
> where this is true?

Prime machines (their native line, not the UNIX boxes they are reselling)
are good exercises for the sloppy at heart.  Prior to PRIMOS 19.4, some
pointers were 32 bits and some were 48 bits.  If memory serves me correctly
(int *) was 32, (char *) was 48.  At some point they changed it so that all
pointers were 48 bits.  Also (char *)0 was definitely not 0L; the extra 16
bits hold information -- segment number or ring number or some such.  As a
general rule, machines with segment architecture do funny things with
pointers that enforce your respect for language rules.

My observation is that funny architectures and such don't matter as long
as your code in lint clean -- you never see the problems because you follow
the rules that avoid the problems.  However these fussy rules are only
for portability freaks.  If your friend is only going to have one job in
his life, work on only one machine in his life, and only use one compiler
I see no reason why he should worry about these issues.
-- 
Richard Harter, Software Maintenance and Development Systems, Inc.
Net address: jjmhome!smds!rh Phone: 508-369-7398 
US Mail: SMDS Inc., PO Box 555, Concord MA 01742
This sentence no verb.  This sentence short.  This signature done.



More information about the Comp.lang.c mailing list