On 3/28/13, cal wrote:
> Just realized that format.d is able to figure it out, since it
> prints #{overlap...} for unions. I can use that code, which works
> regardless of protection. Thanks
Ah, I didn't even know .tupleof would contain .offsetof.
void main()
{
static if (S.tupleof[0].offset
On Thursday, 28 March 2013 at 20:18:45 UTC, Andrej Mitrovic wrote:
On Thursday, 28 March 2013 at 20:02:18 UTC, cal wrote:
.offsetof will also require access rights to the fields.
Just realized that format.d is able to figure it out, since it
prints #{overlap...} for unions. I can use that code
On Thursday, 28 March 2013 at 20:18:45 UTC, Andrej Mitrovic wrote:
.offsetof will also require access rights to the fields.
Yeh this is the problem. I can map data layout of complex
aggregates, even if the members are private, but unions mess that
up. Restricting to public fields is an option
On Thursday, 28 March 2013 at 20:02:18 UTC, cal wrote:
is there any way to detect the fact that fields i and f will
have the same offset from S?
void main()
{
static if (S.init.i.offsetof == S.init.f.offsetof)
pragma(msg, "Union");
}
(Creating an instance of S and getting the relat
Given:
struct S {
union {
int i;
float f;
}
}
is there any way to detect the fact that fields i and f will have
the same offset from S? (Creating an instance of S and getting
the relative addresses only works if the union is public).