On Sat, Feb 28, 2015 at 8:20 AM, Thomas Jakway <tjakway@nyu.edu> wrote:
I'm very new to Haskell and am trying to write a "real" program to motivate myself to learn it better (so far I've only gotten through Project Euler problems after reading LYAH and most of RWH).  I'm using Taglib (https://github.com/taglib/taglib) to read the metadata from a music file and print it.  I have a struct C-side (with C linkage) serving as the bridge between Taglib's C++ and Haskell's FFI.  A small demo program (compiled with gcc and linked against the C++ object files) gives the correct results, but Haskell is weirdly only getting some of it right.  Specifically, the C string fields are working but ints are not.

The raw FFI is unfriendly, but also not really intended for direct use except in very simple cases. You probably want to look into c2hs (or gtk2hsc2hs which is a fork that supports more complex C headers) to generate the FFI declarations, rather than try to manipulate structs directly.

--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net