[comp.lang.c] pointer comparisons on PC

daveh@marob.masa.com (Dave Hammond) (12/11/89)

Thanks to all who responded to my inquiry about pointer comparison on
the PC.  Perhaps you'll indulge me a bit longer.  The program is being
compiled in the Large model, but the normalization process does not
appear to occur with automatic storage, only external.  Am I correct in
assuming that stack variables are always treated as Small model, since
the stack must fit in a 64k segment ?

Finally, does anyone have suggestions on C compilers for the PC which
are better suited for development than Turbo-C ? Are there compilers
which will do pointer normalization all the time (and allow me to port
software to DOS without having to scan thousands of lines to determine
where "huge" has to be inserted :-<)

Thanks, again.

--
Dave Hammond
daveh@marob.masa.com
daveh@dsix2.uucp

few@quad1.quad.com (Frank Whaley) (12/13/89)

In article <2583A4BE.697A@marob.masa.com> daveh@marob.masa.com (Dave Hammond) writes:
>Thanks to all who responded to my inquiry about pointer comparison on
>the PC.  Perhaps you'll indulge me a bit longer.  The program is being
>compiled in the Large model, but the normalization process does not
>appear to occur with automatic storage, only external.  Am I correct in
>assuming that stack variables are always treated as Small model, since
>the stack must fit in a 64k segment ?

Before this gets out of hand let me point out that I got a note from Dave
with a sample program that displays his problem.  He, like many of us,
missed the fact that TC follows the tradition of previous compilers in
providing a default 4K stack for the large data models.  His sample program
allocated just over 4K of automatic variables and thus was able to
easily demonstrate segment wrap when printing only the offset portion of a
far pointer.

Since the stack is allocated by the run-time (and may be of any size up
to 64K), the compiler cannot know when you are allocating more stack
space than will exist later.  I forgot to tell Dave that if he had turned
stack checking on (with the -N flag), his sample program would have
immediately produced a stack overflow error and exited.

>Finally, does anyone have suggestions on C compilers for the PC which
>are better suited for development than Turbo-C ? Are there compilers
>which will do pointer normalization all the time (and allow me to port
>software to DOS without having to scan thousands of lines to determine
>where "huge" has to be inserted :-<)

All of the PC C compilers I use produce remarkably similar results when
presented with violations of segmented architecture silliness.
-- 
Frank Whaley
Senior Development Engineer
Quadratron Systems Incorporated
few@quad1.quad.com
uunet!ccicpg!quad1!few

Water separates the people of the world;
Wine unites them.