Hi, thanks for the reply. I did not mean that I do not know how to use the function this way. For example, {#fun foo { `String' -- string , `Int' } -- string length -> IO () #} Where should I put the withCStringLen*?
2009/11/24 Thomas DuBuisson <thomas.dubuis...@gmail.com>: > 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#v:withCStringLen > > 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.magiclo...@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 >> > -- 竹密岂妨流水过 山高哪阻野云飞 _______________________________________________ C2hs mailing list C2hs@haskell.org http://www.haskell.org/mailman/listinfo/c2hs