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 3816E7F30A for ; Fri, 1 Mar 2013 12:40:47 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of christoph.bauer@lmsintl.com) identity=pra; client-ip=195.245.231.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.bauer@lmsintl.com"; x-sender="christoph.bauer@lmsintl.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of christoph.bauer@lmsintl.com designates 195.245.231.130 as permitted sender) identity=mailfrom; client-ip=195.245.231.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.bauer@lmsintl.com"; x-sender="christoph.bauer@lmsintl.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail1.bemta5.messagelabs.com) identity=helo; client-ip=195.245.231.130; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.bauer@lmsintl.com"; x-sender="postmaster@mail1.bemta5.messagelabs.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnkCAHyTMFHD9eeCiWdsb2JhbABFsDWOdoMIfxYOAQEBCgsSFAUigh8BAQEEbhcEAgEIEQQBAQ4aBzITAQkIAQEEARIICodvAxMIrWIBAYlDA4lLjmM4BoJZYQOINY8shHuNW4Im X-IPAS-Result: AnkCAHyTMFHD9eeCiWdsb2JhbABFsDWOdoMIfxYOAQEBCgsSFAUigh8BAQEEbhcEAgEIEQQBAQ4aBzITAQkIAQEEARIICodvAxMIrWIBAYlDA4lLjmM4BoJZYQOINY8shHuNW4Im X-IronPort-AV: E=Sophos;i="4.84,761,1355094000"; d="scan'208";a="5021989" Received: from mail1.bemta5.messagelabs.com ([195.245.231.130]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 01 Mar 2013 12:40:21 +0100 Received: from [85.158.139.19:61211] by server-16.bemta-5.messagelabs.com id C5/CC-02543-4A390315; Fri, 01 Mar 2013 11:40:20 +0000 X-Env-Sender: christoph.bauer@lmsintl.com X-Msg-Ref: server-7.tower-178.messagelabs.com!1362138020!27302462!1 X-Originating-IP: [217.110.84.214] X-StarScan-Received: X-StarScan-Version: 6.8.6; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21161 invoked from network); 1 Mar 2013 11:40:20 -0000 Received: from unknown (HELO KAIP-EXHUB01.lmsintl.com) (217.110.84.214) by server-7.tower-178.messagelabs.com with RC4-SHA encrypted SMTP; 1 Mar 2013 11:40:20 -0000 Received: from KAIP-EXMSG01.lmsintl.com ([10.2.100.91]) by KAIP-EXHUB01.lmsintl.com ([10.2.100.90]) with mapi; Fri, 1 Mar 2013 12:40:20 +0100 From: Christoph Bauer To: Romain Bardou , "caml-list@inria.fr" Date: Fri, 1 Mar 2013 12:40:19 +0100 Thread-Topic: [Caml-list] C Interface question about failwith Thread-Index: Ac4WbYlJMr5iugFMSbeT9EAF7NTBWQAAhPAQ Message-ID: <9A8556989A396A408C72088C69EDE56308AE441B10@KAIP-EXMSG01.lmsintl.com> References: <9A8556989A396A408C72088C69EDE56308AE441AFF@KAIP-EXMSG01.lmsintl.com> <51308CCA.3020904@inria.fr> In-Reply-To: <51308CCA.3020904@inria.fr> Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: de-DE, en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [Caml-list] C Interface question about failwith Hello Romain, Great idea, this will definitely work. Thanks! By checking asmrun/fail.c I also understand the link error: caml_global_dat= a is only used for bytecode. With ocamlopt, this could work: static void failwith_string_value(value msg) Noreturn; typedef value caml_generated_constant[1]; extern caml_generated_constant caml_exn_Failure; static void failwith_string_value(value msg) { CAMLparam1(msg); caml_raise_with_arg((value)caml_exn_Failure, msg); CAMLnoreturn; } Kind Regards, Christoph Bauer -----Original Message----- From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Beh= alf Of Romain Bardou Sent: Freitag, 1. M=E4rz 2013 12:11 To: caml-list@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 =E9crit : > Hi, > > In C code I have a malloced-string error message, which must be freed.=20 > 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 =3D caml_copy_string(s); > free(s); > failwith_string_value(msg); > > > But FAILURE_EXN is not defined in fail.h and more important=20 > caml_global_data is defined in mlvalues.h, but I get an undefined referen= ce link error. > > Any ideas how to solve such a problem? > > Thanks, > Christoph Bauer > > > > > -- Caml-list mailing list. Subscription management and archives: https://sympa.inria.fr/sympa/arc/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs