From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id AD0F07F30A for ; Fri, 1 Mar 2013 12:11:06 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.84,761,1355094000"; d="scan'208";a="5017636" Received: from dhcp-rocq-27.inria.fr (HELO [128.93.62.27]) ([128.93.62.27]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 01 Mar 2013 12:11:06 +0100 Message-ID: <51308CCA.3020904@inria.fr> Date: Fri, 01 Mar 2013 12:11:06 +0100 From: Romain Bardou User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: caml-list@inria.fr References: <9A8556989A396A408C72088C69EDE56308AE441AFF@KAIP-EXMSG01.lmsintl.com> In-Reply-To: <9A8556989A396A408C72088C69EDE56308AE441AFF@KAIP-EXMSG01.lmsintl.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Validation-by: romain.bardou@inria.fr Subject: Re: [Caml-list] C Interface question about failwith 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 > > > > >