On Wed, 2004-02-04 at 13:36, Leopold Toetsch wrote: > > 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. Exactly my worry. Does it depend on the compiler? Architecture? Libraries? C specification? Phase of the moon? > But I'd say that there are four adjacent Uint8 taking one word, then is > another word (SDLkey sym). Or a structure starts aligned ... I ran this program in lieu of the debugger: #include <stdio.h> #include <stdlib.h> #include <SDL/SDL_events.h> int main () { SDL_KeyboardEvent kbevent; printf( "0x%08X event\n", &kbevent ); printf( "0x%08X event.type\n", &kbevent.type ); printf( "0x%08X event.which\n", &kbevent.which ); printf( "0x%08X event.state\n", &kbevent.state ); printf( "0x%08X event.keysym.scancode\n", &kbevent.keysym.scancode ); printf( "0x%08X event.keysym.sym\n", &kbevent.keysym.sym ); printf( "0x%08X event.keysym.mod\n", &kbevent.keysym.mod ); printf( "0x%08X event.keysym.unicode\n", &kbevent.keysym.unicode ); return(0); } Here's the output on my machine: 0x7FFFF7E8 event 0x7FFFF7E8 event.type 0x7FFFF7E9 event.which 0x7FFFF7EA event.state 0x7FFFF7EC event.keysym.scancode 0x7FFFF7F0 event.keysym.sym 0x7FFFF7F4 event.keysym.mod 0x7FFFF7F8 event.keysym.unicode > 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. Inlining's not a problem; it only has to be done once. This is one spot where C's lack of abstraction actually helps. :) -- c