Hello,
looking at your portion of code I think the problem comes from your
first query calling absolute_file_name/2. When you close this query you
use PL_RECOVER which means that all Prolog stacks are restored, in
particular the Prolog heap. So you should not trust any Prolog term
computed by the query because maybe it is in the heap (this portion of
the heap will be reused in the next query). Here are possible solutions:
- don't call absolute_file_name/2 (consult/1 does it for you !).
See extract below:
- in your first query replace Pl_Query_End(PL_RECOVER)
by Pl_Query_End(PL_CUT)
- in your first query replace Pl_Query_Begin(PL_TRUE)
by Pl_Query_Begin(PL_FALSE)
- in your first query replace arg[0] = arg[1]; by arg[0] = Pl_Mk_Atom(Pl_Rd_Atom(arg[1]));
All these solutions should work.
About Pl_Write_Simple(): you can use it to display a Prolog term like
this:
arg[0] = Pl_Mk_String("new_main.pl");
printf("consulting "); Pl_Write_Simple(arg[0]);
printf("...\n");
func = Pl_Find_Atom("consult");
Pl_Query_Begin(PL_TRUE);
res = Pl_Query_Call(func, 1, arg);
if (res == PL_EXCEPTION) {
printf("exception "); Pl_Write_Simple(Pl_Get_Exception());
printf("\n");
}
Daniel
josh b a écrit :
Hey,
pl2wam was not in my path, so I added it. Didn't make any difference.
I could not find any function called Pl_Write_Simple(), however, I did
try various things like Pl_Rd_String() and
Pl_Exec_Continuation(Pl_Find_Atom("throw"), 1, &except); (Where
except was the variable returned from Pl_Get_Exception()).
However, doing anything with except produces an access violation error.
In fact, doing anything with any term after trying to consult causes
access violations, even with terms that were available and working
before hand and were unmodified. Additionally, using
Pl_Exec_Continuation anywhere in the code seems to cause a violation.
Initially to get it to work, I had to recompile Prolog, using the
instructions (Followed exactly, save for directory locations) found at
http://lists.gnu.org/archive/html/bug-prolog/2009-11/msg00002.html Just
wondering if that could be causing all these violations.
Cheers,
Josh
Find it on Domain.com.au Need
a new place to live?
--
Ce message a été vérifié par
MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.
--
Ce message a été vérifié par
MailScanner
pour des virus ou des polluriels et rien de
suspect n'a été trouvé.
|