Memory Models

Karl Heuer karl at haddock.ima.isc.com
Mon Aug 28 10:06:47 AEST 1989


In article <671 at philmtl.philips.ca> ray at philmtl.philips.ca (Raymond Dunn) writes:
>[In huge model] there are obvious difficulties with sizeof and pointer
>subtraction unless the appropriate cast is used.  This is of course a
>consequence of an int being 16 bits, not of the segmentation.

If the vendor would implement Real ANSI C instead of a close approximation
that coddles to existing code that assumes too much about array sizes, these
difficulties would go away.  The correct typedefs for huge model are:
	typedef unsigned long int size_t;
	typedef long int ptrdiff_t;
With these in place, everything works fine without casts (provided the user is
actually using these types, and not assuming that |int| always works).  An
implementation that always typedefs size_t to be a 16-bit object, and requires
the user to attach a cast to sizeof() in huge model, is BROKEN.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list