[eclipse-users] invoking module function from C API

From: Carlos Gonzalez-Cadenas <carlos_at_...80...>
Date: Fri, 14 Sep 2007 14:16:08 +0200
Hi,

I have the following module installed in the lib directory of Eclipse:

:- module(calendric_unit).

:- lib(ic).
:- lib(calendar).

:- export
    interval/3,        % interval(julian_time, interval_type, result)

interval(X,month,Interval) :- mjd_to_date(X, D/M/Y), date_to_mjd(1/M/Y,Ini),
Tmp is M+1,date_to_mjd(1/Tmp/Y,End), Interval $>= Ini, Interval $<End.

I'm invoking "interval" from the C API. I want to execute the goal and to
obtain the value in Interval.

My code (in C++) is like this:

#include "eclipseclass.h"
#include <stdio.h>

int main(int argc, char** argv)
    {
        ec_init();

    EC_ref result;

    post_goal(term(EC_functor("import",1), EC_atom("calendric_unit")));
    post_goal(term(EC_functor("interval",3), EC_word(54000),
EC_atom("month"), result));

        if (EC_succeed == EC_resume()){
        printf("\nok");
    }else{
        printf("\nfail");
    }
        ec_cleanup();
    }

I can compile the program sucessfully, but when I execute it I get the
following error:

calling an undefined procedure interval(54000, month, _1075) in module
eclipse

Segmentation fault (core dumped)

I can sucessfully compile and execute simple examples, for example the
writeln ones that come in the documentation.

Could you help me?

Many thanks in advance,

Carlos
Received on Fri Sep 14 2007 - 13:16:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 16 2024 - 09:13:19 CEST