Xenix286 Wonders, Bugs, and Patches...
Jonathan W. Krueger
jonk at tekigm.UUCP
Wed May 15 05:52:09 AEST 1985
'#define'ing NULL to be simply 0 (zero) can and will screw up C programs
on the '286 (or '86) which make the assumption that
sizeof(int) == sizeof(int *). The following exemplefies this:
baz()
{
...
foo( NULL, more_args_of_various_sizes, ... );
...
}
foo( p, more_params_of_various_sizes, ... );
struct whatever *p;
typeof more_para....;
{ if ( p == NULL ) /* then */ { ... }
...
}
The Xenix '286 C compiler generates the call to foo with an "int" 0 (2 bytes),
not a "long" 0 (4 bytes). foo expects 4 bytes in that position. This is
partly why on Xenix-286 you find three (or more) packagings of the standard C
library: one for each compiler memory model, small, medium and large. Another
reason is that larger programs need to use "far jumps" rather than "near
jumps."
Of course, I trust you to tell me if I'm wrong.
-- Humbly,
Jonathan W. Krueger
...ihnp4!tektronix!tekigm!jonk
"To change my opinion,
you must first change my reality."
More information about the Comp.unix.wizards
mailing list