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 3594D7F30E for ; Tue, 12 Mar 2013 15:54:54 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.84,831,1355094000"; d="scan'208";a="7077216" Received: from dhcp-rocq-221.inria.fr (HELO [128.93.62.221]) ([128.93.62.221]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-CAMELLIA256-SHA; 12 Mar 2013 15:54:54 +0100 Message-ID: <513F41BC.7070509@inria.fr> Date: Tue, 12 Mar 2013 15:54:52 +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 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Validation-by: romain.bardou@inria.fr Subject: [Caml-list] Auxiliary C function which manipulates the OCaml heap Hello, I have a C function "aux" which may either: - raise an OCaml exception with caml_raise_with_arg; - return void. The argument of caml_raise_with_arg is allocated in "aux". So I should be careful and declare it to the GC. I do so using CAMLlocal. However, this function does not use CAMLreturn, as it does not return an OCaml value but a C value (actually void). So the compiler emits a warning: "unused variable 'caml__frame'" if I use CAMLparam in aux. Is it ok to call CAMLlocal in this way? The documentation says it cannot be called inside nested blocks. Is an auxiliary function considered a nested block? Note that the caller of "aux", or (in another case) the caller of the caller of "aux", has called CAMLparam. If this was not the case, would it make a difference? Similarly, if "aux" had some OCaml value arguments, should it call CAMLparam even though the caller of "aux" has declared them to the GC using CAMLparam or CAMLlocal? Similarly, if "aux" did return an OCaml value, should it call CAMLreturn (and thus CAMLparam) to return the value, or should it use the normal "return"? Thanks, -- Romain Bardou