How to handle nested structs when converting C headers?

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Dec 11 16:04:07 PST 2013


On Thu, Dec 12, 2013 at 12:54:58AM +0100, Gary Willoughby wrote:
> On Wednesday, 11 December 2013 at 23:38:13 UTC, Adam D. Ruppe wrote:
> >On Wednesday, 11 December 2013 at 23:35:04 UTC, Gary Willoughby
> >wrote:
> >>   static union internalRep
> >
> >
> >try
> >
> >static union InternalRep { /* note the capital letter */
> >  /* snip */
> >}
> >InternalRep internalRep;; // still need a decl
> 
> Right. But why use the static keyword here?

Because nested structs by default carry a pointer to the containing
struct (or scope), which means it adds extra baggage and you can't
create the nested without also having an instance of the containing
struct.


T

-- 
It is of the new things that men tire --- of fashions and proposals and
improvements and change. It is the old things that startle and
intoxicate. It is the old things that are young. -- G.K. Chesterton


More information about the Digitalmars-d-learn mailing list