Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 04, 2005 offsetof bug | ||||
---|---|---|---|---|
| ||||
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 Re: offsetof bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | "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 Re: offsetof bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | "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 Re: offsetof bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | 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 Re: offsetof bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Uwe Salomon | "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! |
Copyright © 1999-2021 by the D Language Foundation