From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chris Vine Newsgroups: gmane.lisp.guile.user Subject: Re: How to add Guile support to a package Date: Mon, 5 Jan 2015 16:27:37 +0000 Message-ID: <20150105162737.1a556f5a@bother.homenet> References: <4850D445-1C26-4463-9D95-3883943E438A@telia.com> <20150105131811.766a8813@bother.homenet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1420475288 2567 80.91.229.3 (5 Jan 2015 16:28:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 5 Jan 2015 16:28:08 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Jan 05 17:27:59 2015 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Y8AVb-0007Ax-Bk for guile-user@m.gmane.org; Mon, 05 Jan 2015 17:27:59 +0100 Original-Received: from localhost ([::1]:32817 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8AVa-00020C-QC for guile-user@m.gmane.org; Mon, 05 Jan 2015 11:27:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8AVM-0001wy-A4 for guile-user@gnu.org; Mon, 05 Jan 2015 11:27:45 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y8AVI-0001cy-Gx for guile-user@gnu.org; Mon, 05 Jan 2015 11:27:44 -0500 Original-Received: from smtpout3.wanadoo.co.uk ([80.12.242.59]:34859 helo=smtpout.wanadoo.co.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y8AVI-0001cZ-8m for guile-user@gnu.org; Mon, 05 Jan 2015 11:27:40 -0500 Original-Received: from laptop.homenet ([2.25.43.65]) by mwinf5d45 with ME id cGTd1p00A1QMmXW03GTdGQ; Mon, 05 Jan 2015 17:27:37 +0100 X-ME-Helo: laptop.homenet X-ME-Date: Mon, 05 Jan 2015 17:27:37 +0100 X-ME-IP: 2.25.43.65 Original-Received: from bother.homenet (localhost [127.0.0.1]) by laptop.homenet (Postfix) with ESMTP id EC4598C201 for ; Mon, 5 Jan 2015 16:27:37 +0000 (GMT) In-Reply-To: X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; i686-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.12.242.59 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11704 Archived-At: On Mon, 5 Jan 2015 15:44:16 +0100 Hans Aberg wrote: > > On 5 Jan 2015, at 14:18, Chris Vine > > wrote: > >=20 > > On Mon, 5 Jan 2015 11:05:31 +0100 > > Hans Aberg wrote: >=20 > >> 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. > >=20 > > 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=E2=80=99ed. >=20 > 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. =20 >=20 > 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. >=20 > 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