[plt-scheme] How to define C-structure type with bit fields using FFI?

From: Nikolay Artamonov (artamonov at newecoalt.ru)
Date: Tue Sep 26 13:41:41 EDT 2006

Hi all!

Is it possible to define C-structure type, using FFI, for structure with 
bit fields? For example, we have this structure in C-side:

typedef struct{
   Uint32 hw_available:1;
   Uint32 wm_available:1;
   Uint32 blit_hw:1;
   Uint32 blit_hw_CC:1;
   Uint32 blit_hw_A:1;
   Uint32 blit_sw:1;
   Uint32 blit_sw_CC:1;
   Uint32 blit_sw_A:1;
   Uint32 blit_fill;
   Uint32 video_mem;
   SDL_PixelFormat *vfmt;
} SDL_VideoInfo;

(This is real structure from SDL library - http://www.libsdl.org)

And how we can express that structure in our Scheme-wrapper with, for 
example, define-cstruct? Are there direct ways for it, or we should 
write some auxiliary C-code or even MzScheme extension?


Nikolay Artamonov

Posted on the users mailing list.