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 relative addresses only works if the union is public).

.offsetof will also require access rights to the fields.

Reply via email to