On 07/10/2017 11:14 PM, FoxyBrown wrote:
auto GetStaticAddress(T)()
{
mixin("auto p = cast(T*)"~__traits(allMembers, T)[0]~";");
return p;
}
Returns the address of a struct's static members.
No, it returns the address of T's first member.
It's pretty obvious, the compiler seems to
On 7/11/2017 6:14 AM, FoxyBrown wrote:
On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
No, it isn't. Static members are stored in an entirely different place
than non-static members. They are really just global variables in
memory with their in-source name being nested
On 07/10/2017 02:14 PM, FoxyBrown wrote:
> On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
>> On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
>>> Cannot get the offset of static members of a struct
>>
>> That's because static members do not have an offset. They are not
On Monday, 10 July 2017 at 20:13:46 UTC, Adam D. Ruppe wrote:
On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
Cannot get the offset of static members of a struct
That's because static members do not have an offset. They are
not part of the struct in memory, just in name.
We can
Cannot get the offset of static members of a struct
struct X
{
__gshared public:
int x;
}
X.x.offsetof < invalid.
We can clearly get a pointer to the static struct X since is
effectively the address of X(regardless nomenclature and
terminology issues in D trying to hide this).
On Monday, 10 July 2017 at 20:01:39 UTC, FoxyBrown wrote:
Cannot get the offset of static members of a struct
That's because static members do not have an offset. They are not
part of the struct in memory, just in name.
We can clearly get a pointer to the static struct X
There's barely
Cannot get the offset of static members of a struct
struct X
{
__gshared public:
int x;
}
X.x.offsetof < invalid.
We can clearly get a pointer to the static struct X since is
effectively the address of X(regardless nomenclature and
terminology issues in D trying to hide this).