This isn't part of c2hs but part of Haskells FFI. I suggest you see: http://haskell.org/ghc/docs/latest/html/libraries/base/Foreign-C-String.html... Basically, if you need to call a C routine but your argument for it is a Haskell String then you can convert the Haskell String to a C string before passing: withCStringLen "c2hs has nothing to do with this" ( \(strPtr, strLen) -> some_imported_c_function strPtr strLen) As for the code being different in c2hs - its the same except where you are using special c2hs macros {# ... #}. If you haven't already seen the tutorial [1], I suggest you read that as a start. Also, its easier to help if you include the code you mention. Cheers, Thomas [1] http://www.cse.unsw.edu.au/~chak/haskell/c2hs/docu/ On Tue, Nov 24, 2009 at 3:23 AM, Magicloud Magiclouds <magicloud.magiclouds@gmail.com> wrote:
Hi, I am new to c2hs, while learning and trying it out, I am confused on how to use withCStringLen. Well, I mean how to use it in .chs file, since the code style is a little different from .hs. Thanks. -- 竹密岂妨流水过 山高哪阻野云飞 _______________________________________________ C2hs mailing list C2hs@haskell.org http://www.haskell.org/mailman/listinfo/c2hs