More C interfacing issues

Ian Lynagh igloo at earth.li
Tue Jul 2 13:57:39 EDT 2002


On Tue, Jul 02, 2002 at 06:34:02PM +0100, Alastair Reid wrote:
> 
> > Firstly, some ncurses calls return a *WINDOW and others take one as
> > an argument but you never actually look at the contents of one
> > yourself. I have defined "data Window = Window" and am using Ptr
> > Window for the types of these. However, this means I get a warning
> > about an unused constructor. Is there a better way to do this?
> 
> Hugs supports:
> 
>   data Window
> 
> and I believe GHC and NHC do too.  (Malcolm, SimonM: please shout if I 
> overstate.)

I'd rather stick to H'98+FFI where possible.

> > Secondly, does anyone have any suggestions on how to provide an
> > interface to this?
> 
> >     void getyx(WINDOW *win, int y, int x);
>     
> >     The getyx macro places the current cursor position of the given
> > window in the two integer variables y and x.
> 
> > The type would probably ideally be "Ptr Window -> IO (CInt, CInt)".

[snip]

Thanks to you both for your input - I think I'll go with Sven's two
element array.


Ian





More information about the FFI mailing list