[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: concerns when integrating C++ code into guile?
From: |
Hans Aberg |
Subject: |
Re: concerns when integrating C++ code into guile? |
Date: |
Thu, 8 Jan 2015 10:46:14 +0100 |
> On 8 Jan 2015, at 01:18, Chris Vine <address@hidden> wrote:
>
> On Wed, 7 Jan 2015 23:15:07 +0100
> Hans Aberg <address@hidden> wrote:
>>
>>> On 7 Jan 2015, at 21:24, Ludovic Courtès <address@hidden> wrote:
>>>
>>> If Scheme code calls C++ code that throws an exception, then the
>>> stack will be unwound by libstdc++ and Guile’s ‘dynamic-wind’
>>> handlers and such will not run.
>>
>> If one tries to pass a C++ exception through Guile code, it will not
>> catch in C++ code above it, I think.
>>
>>> That’s probably the main difficulty.
>>
>> There is a gcc option, but someone said it does not work well,
>> perhaps because any intermediate library and package functions must
>> be recompiled as well.
>
> It may or may not work well with respect to unwinding the stack, but
> that misses one half of the point. It won't cause dynwind handlers to
> run, whatever recompilation you do.
If you want that, they must be converted somehow.
>> Another variation might be compile C as C++, i.e. writing Guile in
>> the common C/C++ subset. The Bison skeleton file had that before
>> making a genuine C++ one, though it proved too difficult to maintain,
>> and in addition, one does not get access to C++ features.
>>
>>> Likewise when C++ code calls Scheme code.
>>
>> For this, I made a smob and convert Guile errors to a C++ exception.
>> Might be an overhead problem, though.
>
> It is not just a matter of converting guile exceptions to C++
> exceptions. The issue is that guile propagates its exceptions via long
> jumps up the stack, or the equivalent thereof. These will not run
> non-trivial destructors for C++ objects taken out of scope by the jump
> (and according to the C++ standard, it causes undefined behaviour).
Right.
> This means that any exception handling has to be localized.
>
> That is not impossible. There is not that much libguile code needed to
> run scheme extension code in a C++ program, if that is what you want to
> do.
I decided to not pass C++ (non-PODs) objects or exceptions through Guile code.
The FAQ I mentioned also deals with how to convert objects to proper C before
passing them from C++.
- Re: concerns when integrating C++ code into guile?, (continued)
- Re: concerns when integrating C++ code into guile?, Hans Aberg, 2015/01/07
- Re: concerns when integrating C++ code into guile?, Matt Wette, 2015/01/07
- Re: concerns when integrating C++ code into guile?, Hans Aberg, 2015/01/08
- Re: concerns when integrating C++ code into guile?, Matt Wette, 2015/01/08
- Re: concerns when integrating C++ code into guile?, Hans Aberg, 2015/01/09
Re: concerns when integrating C++ code into guile?, Chris Vine, 2015/01/07
Re: concerns when integrating C++ code into guile?, Hans Aberg, 2015/01/07
Re: concerns when integrating C++ code into guile?, Ludovic Courtès, 2015/01/07