unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Hans Åberg" <haberg-1@telia.com>
To: samuel.barreto8@gmail.com
Cc: guile-user@gnu.org
Subject: Re: good tutorial on extending a c++ project with Guile ?
Date: Mon, 26 Jun 2017 18:09:57 +0200	[thread overview]
Message-ID: <454E05B5-B2A2-4074-9873-84C5A6F9356F@telia.com> (raw)
In-Reply-To: <m2y3se3okt.fsf@umr5557-mendel-sbar.univ-lyon1.fr>


> On 26 Jun 2017, at 14:45, Samuel Barreto <samuel.barreto8@gmail.com> wrote:

> So can anyone point me to a good example or a simple tutorial on how to
> extend C++ with Guile ?

Long ago, I wrote [1], which includes a parser generated with Flex/Bison, and examples how to convert between Guile and C++ exceptions. According to discussions here before, it is bad idea passing C++ exceptions through C code.

One difference is that in general there is no way one can guarantee in a C++ interface that an integer staying the same when passed through Guile, as Scheme does not have a static integer and rational number types, but a single number type. So there need to be checks there.

> I think the main confusion point to me is the
> compilation [dance] between g++ and gcc.

C++ names are mangled, and 'extern "C"' drops that, so that the names can be combined with C. If you compile C with g++, I think it will assume it is compile it as C++ with name mangling then.

The Makefile of [1] compiles C++ with g++, but links using gcc with the option '-lstdc++', but perhaps it works using g++, as long it involves no C file compiling.

1. https://secure2.storegate.com/Shares/Home.aspx?ShareID=56659ce2-127e-455e-ba1f-e6cbc82ba973





  parent reply	other threads:[~2017-06-26 16:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-26 12:45 good tutorial on extending a c++ project with Guile ? Samuel Barreto
2017-06-26 13:03 ` Panicz Maciej Godek
2017-06-26 13:08   ` Panicz Maciej Godek
2017-06-26 16:09 ` Hans Åberg [this message]
2017-06-26 16:54 ` David Kastrup
2017-06-26 18:42 ` Chris Vine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=454E05B5-B2A2-4074-9873-84C5A6F9356F@telia.com \
    --to=haberg-1@telia.com \
    --cc=guile-user@gnu.org \
    --cc=samuel.barreto8@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).