
On Fri, Nov 7, 2008 at 3:46 AM, Lutz Donnerhacke
* Michael D. Adams wrote:
But as far as I can tell, hsc2hs doesn't support bit fields. On top of that I'm not sure I can make any safe assumptions about what order the bit fields are packed (LSB or MSB first).
...
The only portable way to get access to C defined structures is involving a C compiler, either using hsc or a C helper module.
I don't think hsc2hs provides that support natively. (I would love to be proven wrong about that.) However, I think it would be reasonable to extend hsc2hs. I've attached a basic draft of an extension that would make hsc2hs support this. Basically this extra template file adds #{peek_bit <type>,<field>} and #{poke_bit <type>,<field>} which present basically the same interface as #{peek} and #{poke} but specialized with some extra smarts to support bit-fields. I probably won't have time to refine this code, but if others find this code to be useful, feel free to take and use code and maybe we can get some proper support into hsc2hs someday. *nudge nudge* Michael D. Adams adamsmd@cs.indiana.edu