Thread overview
Feature request: <struct>.offsetof(<member>) property
Feb 24, 2003
Dan Liebgold
Feb 24, 2003
Walter
February 24, 2003
What I would like to have is a <type>.offsetof(<datamember>) property for struct
or union types. In C/C++ the preprocessor is used for this purpose, for example
(from windows):

#define FIELD_OFFSET(type, field)    ((ulong)(ulong*)&(((type *)0)->field))

Is there currently a way to do this in D?

Dan


February 24, 2003
Good idea. Maybe it can be done in an OO way as a static property:

<struct>.<member>.offset

"Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b3cluc$23e8$1@digitaldaemon.com...
>
> What I would like to have is a <type>.offsetof(<datamember>) property for
struct
> or union types. In C/C++ the preprocessor is used for this purpose, for
example
> (from windows):
>
> #define FIELD_OFFSET(type, field)    ((ulong)(ulong*)&(((type
*)0)->field))
>
> Is there currently a way to do this in D?
>
> Dan
>
>


February 24, 2003
"Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b3cluc$23e8$1@digitaldaemon.com...
>
> What I would like to have is a <type>.offsetof(<datamember>) property for
struct
> or union types. In C/C++ the preprocessor is used for this purpose, for
example
> (from windows):
>
> #define FIELD_OFFSET(type, field)    ((ulong)(ulong*)&(((type
*)0)->field))
>
> Is there currently a way to do this in D?

Yes; tag.member.offset should do it. -Walter