Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
wrapping external classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-11 (16:21)
From: Florent Monnier <fmonnier@l...>
Subject: Re: [Caml-list] wrapping external classes
> >     (* use a destroy method explicitly if you need to make sure the
> > destructor * is called --- Gc.finalise doesn't guarantee this (e.g. the
> > program might * terminate before the finalisation function is executed)

you can use at_exit to garanty a call before termination

> If the handle is really an OCaml integer, it is not possible to attach a
> finalizer to it. The finalizer could be attached to the object that
> wraps the handle; but the best solution is to use custom blocks and C
> finalizers in the C binding.

if you are not so fluent in C/C++ there is this work-around that does work:
but indeed the classic way is to use the custom_operations struct: