Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread kyra
Felipe Lessa wrote: Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and while I can live without it, I'd like to

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Duncan Coutts
On Wed, 2008-07-16 at 22:45 -0300, Felipe Lessa wrote: Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread kyra
If the struct is passed by reference of course then you're fine, but if it's by value then you need a C wrapper. The reason is because it's beyond the scope of the FFI to know the structure layout and how to map that to haskell types. That's the domain of FFI pre-processors. However I don't know

RE: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Duncan Coutts Sent: 17 July 2008 12:46 On Wed, 2008-07-16 at 22:45 -0300, Felipe Lessa wrote: Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Felipe Lessa
On Thu, Jul 17, 2008 at 12:08 PM, kyra [EMAIL PROTECTED] wrote: Yes, but programmer *knows* the structure layout, so she usually can emulate it with a sequence of primary ffi type arguments. It's pretty trivial for the original example (see my previous post on this subj) and can be extended

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Felipe Lessa
On Thu, Jul 17, 2008 at 12:37 PM, Bayley, Alistair [EMAIL PROTECTED] wrote: -- inline your *vect-vect wrapper (ends up in generated .c file) #def void funcWrapper(vect *v) { func(*v); } foreign import stdcall funcWr unsafe funcWrapper :: VectorC - IO () I am using hsc2hs currently, but

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Magnus Therning
Felipe Lessa wrote: Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and while I can live without it, I'd like to

Re: [Haskell-cafe] FFI and struct arguments

2008-07-17 Thread Duncan Coutts
On Thu, 2008-07-17 at 13:36 -0300, Felipe Lessa wrote: I am using hsc2hs currently, but googling about #def with Cabal I found out that some people were having trouble to make Cabal discover that hsc2hs had created a new C file. Specifically, bug #245 [1] which says that the milestone is

[Haskell-cafe] FFI and struct arguments

2008-07-16 Thread Felipe Lessa
Hi, I tried googling and searching the haskellwiki about this but wasn't lucky enough. My question is: is there a way to send struct arguments to C functions via the FFI or do I need to create a C wrapper? I guess there isn't, and while I can live without it, I'd like to leave no doubt.