Re: how to define a struct without padding

2017-05-24 Thread aki via Digitalmars-d-learn
On Thursday, 25 May 2017 at 01:34:35 UTC, Adam D. Ruppe wrote: align(1) struct NAME { align(1): members } My problem is resolved. Thank you for the quick reply. Thanks, Aki

Re: how to define a struct without padding

2017-05-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 25 May 2017 at 01:25:44 UTC, aki wrote: align(1) struct WAVEFORMATEX { align(1) on the outside removes padding from the end. You also need `align(1):` on the inside to move all the padding to the end. align(1) struct NAME { align(1): members }

how to define a struct without padding

2017-05-24 Thread aki via Digitalmars-d-learn
Hi, This is a code ported from some windows C program. It is the Windows WAVE file header definition. The field layout is the same with C, but it has extra 2 bytes at the end, sizeof(WAVEHEADER) in C is 46 while WAVEHEADER.sizeof in D is 48. Why it still have padding in spite of "align(1)" ? How