[Haskell-cafe] c2hs, size_t, and CSize -- argh!

John Van Enk vanenkj at gmail.com
Thu Oct 1 10:20:11 EDT 2009


Hello List,

I'm running into a problem with c2hs and how it parses the C typedef
'size_t'. On 32bit systems, this ends up being parsed as a CUInt. On 64bit
systems, this ends up as a CULong. This gets especially sticky with function
pointers.

In order to make bindings with c2hs that work across the different word
sizes, I have to write an indirection layer in C that defines wrappers for
functions or re-defines typedef's for function pointers to include 'unsigned
long' instead of 'size_t'.

I see there is a ticket open for this:
http://hackage.haskell.org/trac/c2hs/ticket/20

Has any one else run into this issue? Is there a good workaround that
doesn't involve writing a C function/typedef for each collision?

/jve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20091001/88c29b8d/attachment.html


More information about the Haskell-Cafe mailing list