At 10:29 PM 7/11/99 -0600, you wrote:
>What's the best way to refer to offsets within a
>record? I have a struct which I want to write to
>a storage record, sort of like this:
>
>typedef struct
>{
>       Byte    next;
>       etc....
>} StandardDataElement, *StandardDataPtr;
>
>To write it to a record, I used to make a StandardDataPtr  pointer,
>and make it = 0. Then I used to do:
>
>
>DmWrite(myRecPtr,(ULong) pointer->next,&data,1);
>
>While this usually works on the device, it seems to crash the emulator.
>I get a error about reading from low memory. If, instead, I use:
>
>
>DmWrite(myRecPtr,0,&data,1);
>
>it seems to work fine. So if we aren't allowed to use a zero pointer
>to get the offsets, how else can one do this?
>

This has come up a few times, the solution is to try this:

(this define exists in some Palm? header somewhere but I forget where)
#define offsetof(type, member)  ((UInt) &(((type *) 0)->member))

DmWrite(myRecPtr,offsetof(StandardDataElement, next),&data,l);


Reply via email to