Class Field Size/Offsets

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 2 13:49:07 PST 2013


On 3/2/13, Maxime Chevalier <maximechevalierb at gmail.com> wrote:
> To access class fields in machine code generated by my JIT
> compiler, I need to be able to know the offset and size of the
> said fields. It seems that D requires a pointer to an instance of
> the class to make this work.

Shouldn't the following work for you?

class C { int a; int[4] b; }

void main()
{
    pragma(msg, C.a.sizeof);
    pragma(msg, C.a.offsetof);
    pragma(msg, C.b.sizeof);
    pragma(msg, C.b.offsetof);
}


More information about the Digitalmars-d mailing list