[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gprolog.h
From: |
Erick Alphonse |
Subject: |
Re: gprolog.h |
Date: |
Mon, 07 Oct 2002 13:51:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 |
hello,
1. Why when I compile It says error in gprolog.h? (It says, error parse
before template, line 639, I use command g++ -I$QTDIR/include
filename1.cpp filename2.cpp moc_filename1.cpp -L$QTDIR/lib -lqt) And
I'm using gnu prolog 1.2.8
use the latest stable release (1.2.16) to fix this problem
2. How many methods are there in linking prolog to c++? Because some
resources say that we must build a struct and a kind of server in C++
header file. While some people here say that we must put extern C
surround the interface code.
here an example to call C++ procedures from gprolog (should compile if
you modify gprolog.h as I told you before). Note that you need to
specify int as return value instead of bool. See the gplc doc to compile
your .cpp with g++ (as exemplified below).
> test.pl
> :- foreign(pred1(+term),[return(boolean)]).
> :- foreign(pred2(+term),[return(boolean)]).
>
> pred1.cpp
> #include "gprolog.h"
>
> extern "C"
> int pred1(PlTerm p) {
> return true;
> }
>
> pred2.cpp
> #include "gprolog.h"
>
> extern "C"
> int pred2(PlTerm p) {
> return true;
> }
>
> 1022# gplc --c-compiler g++ -L '-lstdc++' test.pl pred1.cpp pred2.cpp -o
> test
Regards,
Erick.