Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!xanth!mcnc!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Memory Models Message-ID: <14446@haddock.ima.isc.com> Date: 28 Aug 89 00:06:47 GMT References: <664@philmtl.philips.ca> <2694@cbnewsc.ATT.COM> <671@philmtl.philips.ca> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 16 In article <671@philmtl.philips.ca> ray@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@haddock.isc.com), The Walking Lint