passing structures from C++ to ECLiPSe

From: Jan Kelbel <>
Date: Wed 17 Aug 2005 09:04:45 AM GMT
Message-ID: <>
I would like to pass some data from C++ to eclipse and back, and
as a first experiment I created in C++ a list of ECLiPSe
structures (according to 3.1.5 in Embedding and interfacing manual) and
passed this list as an argument to an ECLiPSe predicate.

C++ code:
     //compile ecl file with predicate printlist/1

     //create list
     EC_functor task("task",2);
     EC_refs T(3);
     char* names[3] = {"one","two","three"};
     int durations[3] = {1,2,3};

     for (int i=0; i<3; ++i)
         T[i] = term(task,names[i],durations[i]);
     EC_word tasklist = list(T);

     //call predicate printlist/1

     printlist([H|T]) :- arg(1,H,N),writeln(N), printlist(T).

The execution of cpp program ends with error:
instantiation fault in arg(1, _1842, N)

But when I create the list in ECLiPSe
and then execute query
it works.

I don't know whether the structures created in C++ are
in ECLiPSe structures with field names or not, and i don't
know how to access them properly.
Can you tell me, what I'm doing wrong?

I use ECLiPSe 5.8/WinXP/VisualC++ .NET2003

Thanks in advance,
Jan Kelbel
Received on Wed Aug 17 10:13:11 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:39 PM GMT GMT