From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Daniel Skarda <0rfelyus@ucw.cz> Newsgroups: gmane.lisp.guile.devel Subject: Re: What can I do to help? (conclusions) Date: 10 Oct 2002 14:07:23 +0200 Sender: guile-devel-admin@gnu.org Message-ID: References: <20021004132911.GD20754@www> <87k7ky5ggq.fsf@alice.rotty.yi.org> <20021006170804.GA7206@www> <87ofa71nfh.fsf@alice.rotty.yi.org> <87hefzjgng.fsf@zagadka.ping.de> <878z19rl8r.fsf@alice.rotty.yi.org> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1034267817 1708 127.0.0.1 (10 Oct 2002 16:36:57 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 10 Oct 2002 16:36:57 +0000 (UTC) Cc: guile-devel@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17zgIw-0000RA-00 for ; Thu, 10 Oct 2002 18:36:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17zgJ9-0001OP-00; Thu, 10 Oct 2002 12:37:07 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17zgIN-00009I-00 for guile-devel@gnu.org; Thu, 10 Oct 2002 12:36:19 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17zgIL-00008T-00 for guile-devel@gnu.org; Thu, 10 Oct 2002 12:36:18 -0400 Original-Received: from stateless1.tiscali.cz ([213.235.135.70] helo=mail.tiscali.cz) by monty-python.gnu.org with esmtp (Exim 4.10) id 17zgIK-00006Q-00 for guile-devel@gnu.org; Thu, 10 Oct 2002 12:36:17 -0400 Original-Received: from hobitin.ucw.cz (212.11.106.11) by mail.tiscali.cz (6.0.044) id 3DA29C7F0007BFDF; Thu, 10 Oct 2002 18:35:17 +0200 Original-Received: from 0rfelyus by hobitin.ucw.cz with local (Exim 3.36 #1 (Debian)) id 17zc67-00016d-00; Thu, 10 Oct 2002 14:07:23 +0200 Original-To: Andreas Rottmann In-Reply-To: <878z19rl8r.fsf@alice.rotty.yi.org> Original-Lines: 84 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1517 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1517 > > (or link them explicitely with libstdc++). For example you do not > > have to link guile against libgtk to make guile-gtk modules work. > > > Yes, I know that. This is a completly different problem, though. It's > not about the C++ standard lib(s), but about C++ features such as > exceptions and RTTI that must be 'supported' by the main program > (don't ask me for details, however). If you want to _throw_ C++ exception through C code, than yes - libguile has to be compiled using g++. But I do not think this is a good idea - because you bypass Guile exception mechanism and you will not be able to catch C++ exceptions from scheme and vice versa. Recipe I used in my app: wrap all C++ "glue" functions with try/catch and translate C++ exceptions to Scheme. Also all C++ -> Scheme entries must be handled and Scheme exceptions translated to C++. I try to extract helper code from my app and create "libguile++" library, with utilities that are necessary for Guile/C++ integration tasks. > > But do not believe me, it is just a guess few minutes before midnight... > > I have never loaded C++ modules to C program. > > > I don't since I know better ;-) The proof is left as an exercise to > the reader: Just compile some c++ code (and do some exception stuff in > it) into a guile module, and guile will crash on loading this module - > same thing with s/guile/c-linked-app/g. See the code attached bellow - I have not any problems (on Debian Linux, that's it). So reader is confused and tomorow he is going to try some SGI/Sun machines... :-) 0. ;--- Makefile: -------------------------------------------------------- .SUFFIXES: .lo .la CXXFLAGS = $(shell guile-config compile) LDFLAGS = $(shell guile-config link) -rpath $(shell pwd) all: libfoo.la libfoo.la: foo.lo libtool --mode=link $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS) %.lo: %.cc libtool --mode=compile $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $< clean: -rm -rvf .libs *.lo *.la *.a *.so ;--- foo.cc ------------------------------------------------------------------- #include #include static SCM scm_foo (void) try { if (random () & 1) throw "Something very bad happened"; return scm_makfrom0str ("bar"); } catch (const char* desc) { scm_misc_error ("foo", desc, SCM_EOL); return SCM_UNSPECIFIED; } extern "C" void init_foo (void) { scm_c_define_gsubr ("foo", 0,0,0, scm_foo); } ;--- foo.scm ---------------------------------------------------------- (define-module (foo) :use-module (gtk-1.2 dynlink)) (merge-compiled-code "init_foo" "libfoo") _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel