Thread overview
offsetof bug
Jul 04, 2005
Ben Hinkle
Jul 04, 2005
Ben Hinkle
Jul 04, 2005
Uwe Salomon
Jul 04, 2005
Ben Hinkle
July 04, 2005
class Foo {
  int x;
}
void main() {
  Foo.x.offsetof;
}

gives
C:\d>dmd off.d
off.d(5): 'this' is only allowed in non-static member functions
off.d(5): this for x needs to be type Foo not type int


July 04, 2005
"Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:dac0ps$1hh4$1@digitaldaemon.com...
> off.d(5): 'this' is only allowed in non-static member functions
> off.d(5): this for x needs to be type Foo not type int

Might have to do with the fact that class members are free to be rearranged by the compiler.  The compiler may not know the offsets of the members until a later phase.


July 04, 2005
"Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:dac313$1jcg$1@digitaldaemon.com...
> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:dac0ps$1hh4$1@digitaldaemon.com...
>> off.d(5): 'this' is only allowed in non-static member functions
>> off.d(5): this for x needs to be type Foo not type int
>
> Might have to do with the fact that class members are free to be rearranged by the compiler.  The compiler may not know the offsets of the members until a later phase.

The posted example is pretty much the same as the one from the doc (see the Classes page about Field properties). I haven't gotten offsetof to work.


July 04, 2005
On Mon, 04 Jul 2005 21:53:57 +0200, Ben Hinkle <bhinkle@mathworks.com> wrote:

> "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message
> news:dac313$1jcg$1@digitaldaemon.com...
>> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message
>> news:dac0ps$1hh4$1@digitaldaemon.com...
>>> off.d(5): 'this' is only allowed in non-static member functions
>>> off.d(5): this for x needs to be type Foo not type int
>>
>> Might have to do with the fact that class members are free to be
>> rearranged by the compiler.  The compiler may not know the offsets of the
>> members until a later phase.
>
> The posted example is pretty much the same as the one from the doc (see the
> Classes page about Field properties). I haven't gotten offsetof to work.

Please read my post in digitalmars.D. "Ben Hinkle" in the subject :)

Ciao
uwe
July 04, 2005
"Uwe Salomon" <post@uwesalomon.de> wrote in message news:op.stem8xwn6yjbe6@sandmann.maerchenwald.net...
> On Mon, 04 Jul 2005 21:53:57 +0200, Ben Hinkle <bhinkle@mathworks.com> wrote:
>
>> "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:dac313$1jcg$1@digitaldaemon.com...
>>> "Ben Hinkle" <ben.hinkle@gmail.com> wrote in message news:dac0ps$1hh4$1@digitaldaemon.com...
>>>> off.d(5): 'this' is only allowed in non-static member functions
>>>> off.d(5): this for x needs to be type Foo not type int
>>>
>>> Might have to do with the fact that class members are free to be
>>> rearranged by the compiler.  The compiler may not know the offsets of
>>> the
>>> members until a later phase.
>>
>> The posted example is pretty much the same as the one from the doc (see
>> the
>> Classes page about Field properties). I haven't gotten offsetof to work.
>
> Please read my post in digitalmars.D. "Ben Hinkle" in the subject :)
>
> Ciao
> uwe

got it - thanks!