[m-dev.] Socket Library
Julien Fischer
juliensf at csse.unimelb.edu.au
Wed Oct 20 11:12:34 AEDT 2010
On Wed, 20 Oct 2010, Peter Ross wrote:
> Alternatively if you just want to throw an exception from the C code
> directly, write some Mercury code with throws the exception that you
> want and then :- pragma foreign_export it to make it accessible to you
> C code. Then just call the exported name directly. eg
>
> :- pred throw_exception(string::in) is erroneous.
> :- pragma foreign_export("C", throw_exception(in), "c_throw_exception").
>
> throw_exception(Msg) :- throw(some_exception_type(Msg)).
>
> Now you can use c_throw_exception("xxx") directly in your C code.
I don't recommmend doing that -- throwing exceptions across the C
interface like that is undefined for the low-level C backend. (It will
work for the high-level C backend however.)
Julien.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions: mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the developers
mailing list