C union problems (or is a pointer a pointer?)
Kurt Krueger
kurtk at tekcae.CAX.TEK.COM
Thu Apr 27 01:43:17 AEST 1989
On 'real' computers a pointer is generally an absolute virtual memory address.
Casting a pointer is really a NOP, it is only done to keep the compiler happy
(and an attempt to convey that you REALLY know what you are doing).
So in this case, a pointer is a pointer regardless of what it points to.
Now, enter the 80287 (i.e IBM PC). It takes TWO (2, count 'em) 16 bit
quantities to specify a memory address and the formula goes something like
address = segment*16 + offset. Borland has implemented three pointer types
in an attempt to maintain speed but yet address all of memory if possible.
'Near' pointers are just the offset, 'far' pointers are both, but since several
combinations of segment and offset can reference the same address, they have
'huge' pointers which are just normalized far pointers.
In this case a pointer is nowhere near a pointer.
I think you're better off 'unionizing' your pointers and living with the
additional annoyance of union1.union2.pointer. Makes brain damaged processors
more likely to work with your code.
________________________________________________________________________________
|
kurtk at tekcae.CAX.TEK.COM (Kurt Krueger) | Everything runs on smoke. When the
Electrical Simulation Group (ECAX) | smoke leaks out, it stops working.
D.S. 59-432 (503) 627-4363 |
________________________________________|_______________________________________
More information about the Comp.lang.c
mailing list