initializer for struct with anonymous union.

Danni Coy danni.coy at gmail.com
Tue Apr 14 02:42:51 UTC 2026


On Sat, Apr 11, 2026 at 10:23 PM Nick Treleaven via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> On Saturday, 11 April 2026 at 06:56:36 UTC, Danni Coy wrote:
> > On Sat, Apr 11, 2026 at 4:39 PM Danni Coy <danni.coy at gmail.com>
> >> ok with further investigation, linker errors come back as soon
> >> as I add the union into the struct.
> >>
> >> eg
> >>   union u
> >>   {...
> >>   ...}
> >>   u event;
> >> }
> >>
> >> why would my struct now no longer have an initializer?
> >>
> >
> > ok gets weirder - adding an int  to the beginning of the
> > anonymous union removes the linker problem.
> >
> > union
> > {
> >      int _;
> >     EventA a;
> >     EventB b;
> > }
> >
> > Is this a bug, or is there something I am missing?
>
> Can you give the definition of EventA please?
>

 struct EventA
{
    ulong timestamp;
    float x, y;
    ubyte clicks,button;
    bool down;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20260414/5c3f33be/attachment.htm>


More information about the Digitalmars-d-learn mailing list