Newsgroups: comp.os.msdos.djgpp From: design AT netcom DOT com (Chris Waters) Subject: Re: Pointers Message-ID: Organization: Design and Delivery References: <53oa2v$kr4 AT miracle DOT cybernex DOT net> <325FE9B3 DOT 13AB AT cs DOT com> Date: Sat, 12 Oct 1996 22:00:00 GMT Lines: 37 Sender: design AT netcom20 DOT netcom DOT com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <325FE9B3 DOT 13AB AT cs DOT com>, John M. Aldrich wrote: >mrichman AT cybernex DOT net wrote: >> Is it safe to assume that all pointer variables take up the same >> number of bytes, or is that compiler dependent. >16-bit compilers will use 16-bit pointers, and 32-bit compilers will use >32-bit pointers. Untrue; most 16-bit compilers for the x86 offer a choice of 16-bit pointers (small model) or 24-bit pointers (stored in 32-bits as segment:offset; large model). Anyway, I read the question not as: "do different platforms have the same size pointers?" (pretty obviously not true), but as "on a given platform, will pointers to different types of objects be the same size?" And the answer is: not necessarily--though you'll have to search long and hard to find an exception, the standard makes no such guarantee. >Remember, ANSI only provides that short <= int <= long, but does not >dictate the size of int. True, but I don't see the relevance. >Pointers are almost always int-sized, so you can't assume anything about them. Completely false! The size of a pointer is usually based on the size of the address bus, the size of an int on the size of the data bus. Most compilers for the x86 are 16-bit, and offer small and large memory models. Since the small model is useless for all but the simplest programs, that means that for most programs on the most common platform in the world, pointers are not int-sized. OTOH, the question was asked in c.o.m.djgpp for some strange reason. With djgpp, pointers *are* int-sized, but, further, you *can* assume something about the size of ints!! :)