From: Romain Bardou <romain.bardou@inria.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] C Interface question about failwith
Date: Fri, 01 Mar 2013 12:11:06 +0100 [thread overview]
Message-ID: <51308CCA.3020904@inria.fr> (raw)
In-Reply-To: <9A8556989A396A408C72088C69EDE56308AE441AFF@KAIP-EXMSG01.lmsintl.com>
Hello,
I guess you could apply the generic mechanism described in the user manual:
http://caml.inria.fr/pub/docs/manual-ocaml/manual033.html
19.7.3 Registering OCaml exceptions for use in C functions
Maybe Failure is already registered for callback but I don't know…
Cheers,
--
Romain Bardou
Le 01/03/2013 12:06, Christoph Bauer a écrit :
> Hi,
>
> In C code I have a malloced-string error message, which must be freed. But I want also raise an OCaml exception
> with this string. Actually what I need something like this:
>
> static
> void failwith_string_value(value msg)
> {
> CAMLparam1(msg);
> caml_raise_with_arg(Field(caml_global_data, FAILURE_EXN), msg);
> CAMLnoreturn;
> }
>
> Then I could do:
>
>
> msg = caml_copy_string(s);
> free(s);
> failwith_string_value(msg);
>
>
> But FAILURE_EXN is not defined in fail.h and more important
> caml_global_data is defined in mlvalues.h, but I get an undefined reference link error.
>
> Any ideas how to solve such a problem?
>
> Thanks,
> Christoph Bauer
>
>
>
>
>
next prev parent reply other threads:[~2013-03-01 11:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 11:06 Christoph Bauer
2013-03-01 11:11 ` Romain Bardou [this message]
2013-03-01 11:40 ` Christoph Bauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51308CCA.3020904@inria.fr \
--to=romain.bardou@inria.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox