Microport Unix -- Large Model Problems

Guy Harris guy at sun.uucp
Mon Nov 3 20:52:16 AEST 1986


> Another common problem is passing NULL as pointer argument.  NULL is
> #defined as 0, which is 2 bytes.  Large model pointers are 4 bytes, so
> the stack frame is now basically garbage.  The solution is to cast the
> NULLs to the appropriate types.  Ahhh..Intel..you can never be forgiven
> for making us have to worry about memory models...

Yes, having to worry about memory models may be a pain; however, even if you
didn't have multiple memory models, you'd *still* have to worry about
properly declaring pointer-valued functions and casting null pointers.  A
68K implementation might have 16-bit "int"s and 32-bit pointers, or might
return the value of an integral-type-valued function in D0 and the value of
a pointer-valued function in A0.  Other implementations might not use an
all-zero bit pattern to represent a null pointer.

I really hope that when the ANSI C standard comes out, compilers start
issuing warnings if you use a function that you haven't already declared, or
if you don't declare the types of the arguments to a function.  Yes, this
may inconvenience programmers, but the ones it most inconveniences are the
ones who just don't *care* about data types, and they're the ones who need
the biggest attitude adjustment.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.unix.wizards mailing list