Turbo C++ 1.0 Huge pointer addition error?

Doug Gwyn gwyn at smoke.brl.mil
Sun Jan 13 13:32:44 AEST 1991


In article <9101122049.AA28040 at lilac.berkeley.edu> C512052 at UMCVMB.BITNET ("David K. Drum") writes:
- typedef struct { . . . } foo;
- foo huge *hp1,hp2;

That should be
  foo huge *hp1,*hp2;

- hp2 = hp1 + sizeof(foo);
- In my section of code, calculating the 20-bit addresses of hp1 and hp2 and then
- subtracting hp1 from hp2 equals sizeof(foo) squared!

Sounds to me like the compiler is doing precisely what you told it to.
Perhaps you should read up on pointer arithmetic before proceeding.



More information about the Comp.lang.c mailing list