I have the following structure in c# and c++ :
C# [StructLayout(LayoutKind.Sequential)] public struct WAVEFORMATEX { public short wFormatTag; public short nChannels; public int nSamplesPerSec; public int nAvgBytesPerSec; public short nBlockAlign; public short wBitsPerSample; public short cbSize; }
wavFmt = new clsWinMMBase.WAVEFORMATEX(); wavFmt.cbSize = (short)(Marshal.SizeOf(wavFmt));// returns 20
C++typedef struct tWAVEFORMATEX{ WORD wFormatTag; /* format type */ WORD nChannels; /* number of channels (i.e. mono, stereo...) */ DWORD nSamplesPerSec; /* sample rate */ DWORD nAvgBytesPerSec; /* for buffer estimation */ WORD nBlockAlign; /* block size of data */ WORD wBitsPerSample; /* number of bits per sample of mono data */ WORD cbSize; /* the count in bytes of the size of */ /* extra information (after cbSize) */} WAVEFORMATEX WAVEFORMATEX m_stWFEX; m_stWFEX.cbSize=sizeof(WAVEFORMATEX);// returns 18
Why