Luca,
size_t is not a parameter. It is a cast for specific data type.
What this macro does is return the distance (offset) between the beginning
of the structure
and the element of the structure you looking for. As an example on hoe to
use it:
Take this struct
typedef struct
{
char szID [ ID_LEN + 1 ];
char szTitle [ TITLE_LEN + 1 ];
char szActors [ ACTORS_LEN + 1 ];
char Format [ FORMAT_LEN + 1 ];
char szPrice [ PRICE_LEN + 1 ];
char szNumItems [ NUMITEMS_LEN + 1 ];
} OfflineRecord;
if you want to know the offset (distance from the beginning of the
structure) of the szPrice element you do
size_t a = offsetof( OfflineRecord, szPrice);
the return is the number of bytes between the begging and the szPrice
element.
I hope this help
ATTACHMATE CORPORATION
Dalmer Azevedo
mobile Technologies Practice
Voice 650 962 7173
Cell 408 569 6819
-----Original Message-----
From: Luca [mailto:[EMAIL PROTECTED]]
Sent: Thursday, February 10, 2000 1:43 PM
To: Palm Developer Forum
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