gnu prolog

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

gnu prolog

João Mariz Graça
Hi,

I have been reading about gnu prolog,

In the manual there is a chapter about interfacing Prolog an C,
And then, among others, there are also two sub-chapters:
 - Call prolog from C;
 - Call C from prolog.

Is it also possible to call to interace prolog with C++? for instance to call gnu prolog from gtk+ application?

Thanks in advance for any help you can provide,

João 

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

Re: gnu prolog

José Manuel García-Patos
On 25/09/15 12:46, João Mariz Graça wrote:

> Is it also possible to call to interace prolog with C++? for instance to
> call gnu prolog from gtk+ application?

GTK+ is written in C; but even if it weren't, C++ is a superset of C,
so, unless I'm mistaken, whatever applies to C should apply to C++ as well.

Hope that helps.

--
José Manuel García-Patos
Madrid

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog
Reply | Threaded
Open this post in threaded view
|

Re: gnu prolog

Ciprian Dorin Craciun
On Sun, Sep 27, 2015 at 6:59 PM, José Manuel García-Patos
<[hidden email]> wrote:
> On 25/09/15 12:46, João Mariz Graça wrote:
> GTK+ is written in C; but even if it weren't, C++ is a superset of C, so,
> unless I'm mistaken, whatever applies to C should apply to C++ as well.


Unfortunately, due to at-compile-time renaming of functions written in
C++ (to support argument overloading, templates, etc.), you can't
directly link against a C++ function (even if it doesn't use any C++
features).  Usually you'll have to write a wrapper API in C++ that
eliminates all object-oriented (and other C++) features from its
interface (i.e. exported functions), and usually translate pointers to
classes into `typedef void * class_X_t`, which you then have to cast
inside these wrapper functions.  (This functions have to be marked as
`extern "C"`.)

Then you can use these wrapper functions.  However note that linking
also requires additional libraries (that implement the C++ run-time).

(I haven't done this is quite a time, so I can't be more specific than
this, however a good place to look is for example how various C++
libraries are adapted for the Go language.)

Ciprian.

_______________________________________________
Users-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/users-prolog