Reading and converting binary file 2 bits at a time
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 31 11:14:13 PDT 2015
On Monday, 31 August 2015 at 18:00:54 UTC, Andrew Brown wrote:
> Is this correect behaviour?
Yes, the reason is because the nested struct has a hidden member
- a pointer to its stack context. This allows it to access
variables from the surrounding local scope.
It adds 8 bytes on 64 bit cuz that's pointer size, and the other
bytes are padding so the pointer is aligned on a word boundary.
If you change it to `static struct` inside the main function (or
any other function), you'll find it then has the size of one
again, since a static struct does not have access to outer
variables, so it leaves that hidden pointer out.
More information about the Digitalmars-d-learn
mailing list