Re: [eclipse-users] invoking module function from C API

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_cisco.com>
Date: Sun, 16 Sep 2007 17:02:30 +0100
Carlos Gonzalez-Cadenas wrote:
> 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)

                ^^^
	syntax error


> 
> 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
> 

This should work.  Have you checked whether your library
compiles correctly?  Test it with an interactive eclipse
before you use it through the C interface.


-- Joachim
Received on Sun Sep 16 2007 - 17:02:55 CEST

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET