Nasty supprise when using c 'anonymous struct and union' in D with 'static struct'

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Dec 29 20:18:24 UTC 2020


On Tue, Dec 29, 2020 at 12:50:06PM -0500, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 12/29/20 12:45 PM, H. S. Teoh wrote:
[...]
> > You need to add 'static' to the (outer) struct declarations in your
> > unittest block, because otherwise they *will* have a context
> > pointer.
> 
> Not if the struct is POD. And in this case, they are all POD (no
> methods).
[...]

Hmm, I didn't know that!  I thought they always get a context pointer.
Maybe I got confused with nested functions.  I stand corrected.


--T


More information about the Digitalmars-d-learn mailing list