On Mon, Jul 08, 2002 at 08:36:20PM +0100, Alastair Reid wrote:
> 
> > I was expecting the Haskell program and C program attached to
> > produce the same results. However, as shown below, the C program
> > gives identical values for the two pointers whereas the Haskell
> > program gives different ones.
> 
> > [...]
> 
> > Does anyone know what is going on here?  Am I incorrectly using the
> > FFI?
> 
> For what it's worth, I ran Ian's program on Hugs (with minor changes:
> Hugs gets confused by the use of type synonyms in ffi decls)

Is this a hugs bug or am I being non-portable?

> and got
> similar results (on my Linux box):

Should have mentioned that I was using Linux too, and a GHC CVS
snapshot.

> 0x083149b4
> 0x404cc4c4
> 0
> 
> It's so long since I used curses that I can't remember if the two hex
> numbers should match but it's certainly puzzling that they do in C but
> not in Haskell.  

man initscr says:

       The initscr code determines the terminal type and initial�
       izes all curses data structures.  initscr also causes  the
       first  call  to  refresh  to  clear the screen.  If errors
       occur, initscr writes  an  appropriate  error  message  to
       standard error and exits; otherwise, a pointer is returned
       to stdscr.

> Is it at all possible that the Haskell runtimes could have already
> called initscr?  Hugs certainly uses some terminal control magic and
> it's possible that the implementation of termios and curses have
> something in common?  But it seems unlikely that GHC-compiled code
> would do so too.

I hadn't though about that. I don't know how things like readline work,
but I can imagine programs using them not being able to be tested in an
interpreter.

I haven't looked at the ncurses code but I'd have thought if it returned
anything at all it would always return a pointer to stdscr. I might take
a look if I get some time but I really ought to be packing now  :-(

> I take it that if you go the next step and draw something on the
> screens you get different results?

I reached this point having discovered that the Haskell equivalent of
"keypad(stdscr, TRUE)" (insert digression/rant about having to assume
bool is a numerical type in curses here) had no effect but using the
result of initscr worked fine.


Thanks
Ian


_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to