Version française
Home     About     Download     Resources     Contact us    
Browse thread
C-Interface: CAMLreturn and failwith
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bauer, Christoph <Christoph.Bauer@l...>
Subject: C-Interface: CAMLreturn and failwith
Hi,

a question related to CAMLreturn and failwith in C-Stubcode:

Is this code correct:

#include <fail.h>
...

CAMLprim value prim( value unit ) 
{
   CAMLparam0();
   CAMLlocal( result );
   int error;
   /* allocate result, error has an errorcode */
   if( error ) failwith( "error");
   else CAMLreturn( result );
}

or should it be

CAMLprim value prim( value unit ) 
{
   CAMLparam0();
   CAMLlocal( result );
   int error;
   /* allocate result, error has an errorcode */
   if( error ) {
      caml_local_roots = caml__frame;
      failwith( "error");
   }
   else CAMLreturn( result );
} 

Thanks,

Christoph Bauer
Dipl. Inf.

LMS Deutschland GmbH
Luxemburgerstr. 7
D-67657 Kaiserslautern

T +49 631 303 22 152

mailto:Christoph.Bauer@lms-gmbh.de
http://www.lmsintl.com