[Haskell-beginners] FFI Problems

Brandon Allbery allbery.b at gmail.com
Sat Feb 28 15:08:43 UTC 2015


On Sat, Feb 28, 2015 at 8:20 AM, Thomas Jakway <tjakway at 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 at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150228/a17e263a/attachment-0001.html>


More information about the Beginners mailing list