You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following main.pl is an empty file. If it's specified, swipl-ld honours the -goal true and if it's not specified, I get the standard SWI-Prolog banner.
$ swipl-ld -goal true main.cpp main.pl && ./a.out 3.14 a b c ; echo $?
% Disabled autoloading (loaded 34 files)
% Disabled autoloading (loaded 7 files)
% Disabled autoloading (loaded 0 files)
% halt
[./a.out,3.14,a,b,c]
0
$ swipl-ld -goal true main.cpp && ./a.out 3.14 a b c ; echo $?
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.14-DIRTY)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
[./a.out,3.14,a,b,c]
0
$ cat main.cpp
#include "SWI-cpp2.h"
#include <iostream>
int
main(int argc, char *argv[])
{ PlEngine e(argv[0]);
PlTermv av(1);
PlTerm_tail l(av[0]);
for(int i=0; i<argc; i++)
PlCheckFail(l.append(PlTerm_string(argv[i])));
PlCheckFail(l.close());
PlQuery q("writeln", av);
try
{ return q.next_solution() ? 0 : 1;
} catch ( PlException &ex )
{ std::cerr << ex.what() << std::endl;
return 1;
}
}
$ cat main.pl
$
The text was updated successfully, but these errors were encountered:
With a Prolog file (be it empty), it creates a saved state that includes the Prolog flags. Without, it just uses the normal Prolog startup and as you do not pass the goal from your main.cpp to PlEngine, it is lost. The best I can see is to warn that these flags are no-ops if there is no Prolog code passed to swipl-ld.
Documenting it seems a reasonable solution; but your answer also tells me that I don't understand how -goal and the arguments to PlEngine( work. I'll add this to my "documentation to-do list".
In the following
main.pl
is an empty file. If it's specified,swipl-ld
honours the-goal true
and if it's not specified, I get the standard SWI-Prolog banner.The text was updated successfully, but these errors were encountered: