[Haskell-cafe] Need help with very simple C++ FFI call

Brandon Allbery allbery.b at gmail.com
Tue Nov 19 17:17:12 UTC 2013


On Tue, Nov 19, 2013 at 12:13 PM, Thiago Padilha <tpadilha84 at gmail.com>wrote:

> I still dont understand why ghci is not using the default thread to
> run the binding, but from now on I will be more alert when binding to
> libraries that uses threads.
>

-fno-default-sandbox ? (this changes in upcoming ghci, I believe)


> Theres something else I also dont understood about FFI: When trying to
> debug the problem I've written many printf statements  but none of
> them showed on the screen, but now that the example is working I've
> notice that all printed text appears once I exit ghci. Why is that
> happening?
>

Because C/C++ stdio buffers by default, as does Haskell's --- but they are
independent buffers, so the state of the Haskell buffering mode is not
relevant to C/C++ or vice versa and flushing in one does not affect the
other. Evidently the C one is only getting flushed in an atexit() hook.
(You may want to look at setvbuf().)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131119/b7184f39/attachment.html>


More information about the Haskell-Cafe mailing list