guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add Guile support to a package


From: Chris Vine
Subject: Re: How to add Guile support to a package
Date: Mon, 5 Jan 2015 16:27:37 +0000

On Mon, 5 Jan 2015 15:44:16 +0100
Hans Aberg <address@hidden> wrote:
> > On 5 Jan 2015, at 14:18, Chris Vine <address@hidden>
> > wrote:
> > 
> > On Mon, 5 Jan 2015 11:05:31 +0100
> > Hans Aberg <address@hidden> wrote:
> 
> >> There is an issue when using C++ global objects having initializers
> >> doing allocations, on platforms (as on OS X) where the GC
> >> initializer must run first.
> > 
> > Does this include guile-2.0?  That uses the gc library, which seems
> > to require some precautions to be taken on Darwin as regards the
> > loading of dynamic libraries, but I have not heard of problems
> > interfacing with static global objects where those static objects
> > are conventionally allocated rather than GC’ed.
> 
> Guile is written entirely in C, so there is no problem.

You referred to using C++ global objects with gc on Darwin, which is the
subject I am interested in.  You did so presumably because GNU chess
is written in C++.  I am interested in what the specific issue with C++
is, because I have a project to which that may be relevant.  According
to the OP, GNU chess is at present conventionally allocated, so none of
its static data (if any) is at present GC'ed.

> > In any event, I have not had problems getting guile to work as an
> > optional extension language for a C++ program with linux, from the
> > memory allocation point of view.  
> 
> On GNU/Linux, GC_INIT() is not required, so there is no issue there.

Indeed.

> > There are however issues with
> > accommodating guile exceptions, which are basically long jumps, to
> > C++ objects with non-trivial destructors.  You have to organize the
> > code so that no guile exception can take such a C++ object out of
> > scope, and no C++ exception can propagate out of a guile dynwind
> > block.
> 
> If you want to pass C++ exceptions through C-code, there is a gcc
> option for that.

It enables you to pass a C++ exception through (but not catch it in) C
code (in other words, it enables stack unwinding).  However, I do not
think it enables you to throw C++ exceptions out of guile dynwind
blocks and end up with a sensible result (other than program
termination), since C++ exceptions use a different mechanism from
guile's exception jumps.  Leaving aside the point that relying on the
gcc -fexceptions extension for C makes code non-portable, are you
saying it actually works with dynwind blocks?

Chris



reply via email to

[Prev in Thread] Current Thread [Next in Thread]