Questions tagged [c2hs]

c2hs is a generator tool for Haskell bindings to C libraries.

C->Haskell (c2hs) is an interfacing tool that assists in the development of Haskell FFI bindings to C libraries. It gathers interface information like data type definitions and function signatures from C header files and generates Haskell code with foreign imports.

There are some distinctions between c2hs and hsc2hs.

References

Related Tags

38 questions
0
votes
1 answer

What is the proper way to write doc for bindings?

While writing a Haskell binding for some libs written in C, a thing has to do is writing docs in haddock format. But since normally the binding is just plain, the doc would be just reformat of original libs' doc. So my question is, is there some…
Magicloud
  • 818
  • 1
  • 7
  • 17
0
votes
1 answer

How to have c2hs working with ghc CPP extension?

I have some #IF and #ENDIF in .hs. If I just rename the file to .chs, the #IF and #ENDIF are just moved to .h generated by c2hs instead of the .hs generated by c2hs. I did not see this mentioned in…
Magicloud
  • 818
  • 1
  • 7
  • 17
0
votes
1 answer

Using alloca- with c2hs

Consider from the c2hs documentation that this: {#fun notebook_query_tab_label_packing as ^ `(NotebookClass nb, WidgetClass cld)' => {notebook `nb' , widget `cld' , alloca- `Bool' peekBool*, alloca- …
George
  • 6,927
  • 4
  • 34
  • 67
0
votes
2 answers

Haskell how to work with extern FILE* from c?

I want to foreign import a function from some c header, but how to deal with the stderr of type FILE* which defined as: extern FILE* __stderrp; #define stderr __stderrp Maybe not precisely. I use c2hs for my ffi work, and already have: {#pointer…
uuhan
  • 143
  • 6
0
votes
1 answer

Haskell FFI - return updated structure

I have the following C function that I want to call from Haskell: void read_params_for (property_list_t *props); The function is supposed to receive some property_list_t and populate some values within it, so the caller then has an updated…
Alexey Raga
  • 7,457
  • 1
  • 31
  • 40
0
votes
1 answer

How should I debug a "symbol X does not fit here" error when using c2hs?

I'm new to using c2hs and having this issue. I'm not sure how to start debugging this, and haven't found anything with a Google search or by looking through the issues on GitHub. Where should I begin, and what are some resources that could…
Paul Young
  • 1,489
  • 1
  • 15
  • 34
0
votes
2 answers

c2hs installation error with Mac OS X 10.7.5

I'm trying to install c2hs with cabal install c2hs. I created ~/.cabal/bin to install the binary beforehand. With the command cabal install c2hs to get the errors. src/Control/StateTrans.hs:77:1: Warning: Module `Prelude' does not export…
prosseek
  • 182,215
  • 215
  • 566
  • 871
0
votes
1 answer

How do i pass NULL to the foreign function with argument of type char*?

I'm writing Haskell bindings to some C project and there is a function of type void foo(char *); The problem is that foo checks this pointer for NULL value and do something different from normal behavior. In my Haskell source wrapper for this…
arrowd
  • 33,231
  • 8
  • 79
  • 110
1 2
3