Hi !

Again I need some help ... hoping there's anybody here familar with the memory-organization of C/C++ !

While I'm converting the DX8.1-includes I need to convert structures. Although I've did all the Type-Declarations I still try to fill the structures with basic types like DWord, Word, etc.
(I know that this will not be 64-Bit compatible ...)

The problem I have occurs now while making the includes for DirectShow ( and I think there may be many errors in the DMusic-files !)

Many constants are defined by enumerating and the defining type need not to be a 32-bit value. It's possible that it is only a 16 bit or 8-bit type. This may be compiler relevant (Whats the default in Visual C ?)
Boolean have also the size 1 (means 8-Bit value), but the WINDOWS-defined BOOL is a DWord !

But what's the ordering of them in structures ? Will they all be aligned at DWord-Boundary ? Or will couples of four bytes put together in one DWord ?

I havn't got VC - so who can help me ?

The following structure is one of those problematic structures. If no field-alignment will be done the acces of the DWord-values isn't good at all:

_DVD_AudioAttributes STRUCT
AppModeData BYTE ?
Language DWORD ? ; LCID
LanguageExtension DWORD ? ; DVD_AUDIO_LANG_EXT
fHasMultichannelInfo DWORD ? ; BOOL
dwFrequency DWORD ?
bQuantization BYTE ?
bNumberOfChannels BYTE ?
dwReserved DWORD 2 DUP (?)
_DVD_AudioAttributes ENDS

The original types are given by comments ...

The maximum number of the DVD_xxx-constants are

DVD_AUD_EXT_DirectorComments2 EQU 4
DVD_AudioFormat_Other EQU 8
DVD_AudioMode_Other EQU 3

so they seem to be 8-Bit values, or ?

Greetings, CALEB
Posted on 2002-01-13 17:07:29 by Caleb
enum = int = 4bytes // the C standard says enum is int sized
bool = char = 1byte // bool... dunno what the C++ standard says, VC is char.
BOOL = int = 4bytes // windows standard

All structure members are aligned. Can't remember granularity,
but will most likely be either 4, 8 or 16.

btw, shouldn't your signature be "... and the answer is ... "42"",
without the last e in answer? :).
Posted on 2002-01-13 17:26:18 by f0dder
Thanks f0dder !

This dummy mistake with the e - I'was doing so since I have begn to learn english ;)

OK if I get you right, a structure like

MyStructure STRUCT
Val1 BYTE ?
Val2 BYTE ?
Val3 BYTE ?
Val4 BYTE ?
MyStructure ENDS

will reserve 16 bytes if fields are aligned to 4-byte-boundaries, or ?
Posted on 2002-01-13 17:42:49 by Caleb
This will insure DWORDs are always on a four byte boundary:
MyStructure     STRUCT [b]4[/b]

Val1 BYTE ?
Val2 BYTE ?
Val3 BYTE ?
Val4 BYTE ?
MyStructure ENDS
But it would have no effect on the above structure because all the sizes are byte.
MyStructure     STRUCT [b]4[/b]

Val1 BYTE ?
Val2 BYTE ?
Val3 BYTE ?
Val4 DWORD ?
MyStructure ENDS
This structure however is 8 bytes long - MASM aligns the DWORD on four bytes.
Posted on 2002-01-13 18:33:13 by bitRAKE
Thanks bitRake !

This is the answer I need !

Now DShow can come ...

Greetings, CALEB
Posted on 2002-01-13 19:06:38 by Caleb
Bitrake, that is *great* - I always thought I had to do manual
struct padding :D

You got me in a bit of doubt now, by the way. I can't remember if
C compilers usually align all fields, or only the fields that "need"
Posted on 2002-01-14 04:14:07 by f0dder

Thanks for posting it, I learned something new today :)
Posted on 2002-01-14 19:00:29 by dxantos