|Subject:||gplc doesn't work properly with gcc 4.x.x|
|Date:||Wed, 1 Oct 2008 17:41:21 +0200|
I'm working on a i686 AMD Sempron 2400+ under Archlinux, I'm using gcc 4.3.2 and gprolog 1-3.0 (the lastest stable version available right now).
I would like to interface C and Prolog in order to make a solver for some puzzle (written in C) and learn about constraint programming.
So I've carefully read the manual's last chapter and I've tried out the examples in there before going to build up mine, but even some of them don't work properly with gcc 4.3.2!
The last one in gprolog's manual ( section 9.5.1, you can find the source new_main_c.c as far as I know located in ExamplesC folder).
Let's look function Main_Wrapper in there:
Main_Wrapper(int argc, char *argv)
int i, nb_sol = 0;
func = Find_Atom("anc");
printf("\nEnter a name (or 'end' to finish): ");
if (strcmp(str, "end") == 0)
arg = Mk_Variable();
arg = Mk_String(str);
nb_sol = 0;
res = Pl_Query_Call(func, 2, arg);
sol[nb_sol++] = Rd_String(arg);
res = Pl_Query_Next_Solution();
for (i = 0; i < nb_sol; i++)
printf(" solution: %s\n", sol[i]);
printf("%d solution(s)\n", nb_sol);
**** MY EXPLANATION ****
If I run this simple example asking for the john's ancestors list (for further information please look at the prolog file new_main.pl), it simply answers with "peter" while the correct answer was: peter, bob, jane, mary and paul !!
I guess that function Pl_Query_Next_Solution() (look in the while(res) ) doesn't work properly: it always returns FALSE even if there is more than one solution! That's awful, you can't go further than the first result in the query because res is set equal to 0 in the while(res) at the very first attempt (so the while condition becomes FALSE)!
The only workaround I was able to find out is just to install gcc 3.x.x and try again and it worked flawlessly! :-)
Although the query works fine in that way, I'd still prefer using gcc 4.x.x if I could find out how to!
Any suggestions would be nice! Thanks.
p.s. sorry for my BAD English, actually I'm still learning it! Anyway, I hope my message is still intelligible to all of yours. :-D
|[Prev in Thread]||Current Thread||[Next in Thread]|