Chromatic <[EMAIL PROTECTED]> wrote:

> In this case, it doesn't, as the struct I'm emulating is:

>       typedef struct {
>               Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
>               Uint8 which;    /* The keyboard device index */
>               Uint8 state;    /* SDL_PRESSED or SDL_RELEASED */
>               SDL_keysym keysym;
>       } SDL_KeyboardEvent;

> SDL_keysym itself is a struct:

>       typedef struct {
>               Uint8 scancode;         /* hardware specific */
>               SDLKey sym;         /* SDL virtual keysym */
>               SDLMod mod;         /* current key modifiers */
>               Uint16 unicode;         /* translated character */
>       } SDL_keysym;

> SDLKey and SDLMod are both enums.

> As I understand it (and correct me if I'm wrong), SDL_keysym needs a
> byte of padding on my architecture within SDL_KeyboardEvent.

Brr. I don't know. I've to ask my debugger for that :) If you have
SDL_keysym alone, that needs 3 bytes additional alignment. But don't ask
me about the combined structure.

But I'd say that there are four adjacent Uint8 taking one word, then is
another word (SDLkey sym). Or a structure starts aligned ...

We don't have a notion of nested structures. They could go just inline,
i.e. without extra syntax. Pointers to structures are of course missing
too, that's a different thingy.

> I can add
> that padding manually, but I'm not convinced that'll be portable to
> different architectures.

Automatic alignment based on the data type sizes is for sure better.

> -- c

leo

Reply via email to