"size_t" is not a Palm data type. It's a Standard C Library data type. It's
usually equivalent to a signed or unsigned int or long int.
The idea behind "offsetof" is to determine the distance from the start of a
structure to a particular field in the structure, the result being expressed in
bytes.
The way it works is to make the compiler think there's an instance of this
structure at memory location zero, and then to take the address of the field
that you're interested in. With the structure at memory location zero, the
field's location and offset are the same value.
-- Keith Rollin
-- Palm OS Emulator engineer
"Luca" <[EMAIL PROTECTED]> on 02/10/2000 01:43:28 PM
Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent by: "Luca" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
cc: (Keith Rollin/HQ/3Com)
Subject: calculating an offset
I'm trying to find a way to calculate the offset to a field in a structure.
I searched the Knowledge Base and found a macro that could be handy
#define offsetof(type, member) ((size_t) &(((type *) 0)->member))
type: Structure type
member: particular member of the structure
size_t: ??
I can't figure out what size_t is supposed to be (I'm new to Palm
programming. Actually, I'm fairly new to programming in general!). Any
help would be greatly appreciated. Further, if you have the patience an
explanation of the logic behind the operation would be nice.
Thanks in advance
Luca
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palm.com/devzone/mailinglists.html
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html