Alignment of unions
Stewart Gordon
smjg_1998 at yahoo.com
Tue Apr 14 08:50:47 PDT 2009
Don wrote:
> Stewart Gordon wrote:
<snip>
>> That's only because you want to be able to attach alignments to
>> individual members of a union. And I still don't know why.
>
> I'm not sure why you think unions are so different to structs. They are
> identical in most respects -- including requirements for alignment of
> members.
I still don't know what you mean.
>> If you want a union to have a certain alignment relative to a struct
>> in which it's contained, in what cases is it not sufficient to put the
>> align attribute on the union's instance in the struct?
>
> In cases where you don't know what the containing struct is. The union
> may just be a type returned from a template, for example.
If you don't know what the containing struct is, you probably also don't
know what member alignment that struct requires. The person who creates
the struct, OTOH, does know. So why are you trying to do that person's job?
Stewart.
More information about the Digitalmars-d
mailing list