gprolog extended via C interface ignores command-line interface arguments

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

gprolog extended via C interface ignores command-line interface arguments

Simon Curry

Hi,

I am using:

GNU Prolog 1.4.4 (64 bits)
Compiled Dec  1 2017, 19:56:55 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz

running on a ubuntu machine:

Linux simon-Leopard-Extreme 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I am extending gprolog with a significant library of crypto functions in C and in general this works very well. The only exception is that the new instance of gprolog, extended with these functions ignores the '--init-goal', '--query-goal' command line arguments. These are useful for running the prolog application from a cron job, for example.

"Fortunately", your own example in /usr/local/gprolog-1.4.4/examples/ExamplesC manifests the same problem, so I need not burden you with all of my code.

For example, when I build your example and compare the operation of the new executable with that of the base gprolog, I get:


sjswc@simon-Leopard-Extreme:ExamplesC$ gprolog --query-goal "format('Hi Mom', [])"
GNU Prolog 1.4.4 (64 bits)
Compiled May 15 2017, 21:17:39 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?- format('Hi Mom', []).
Hi Mom

yes
| ?-

sjswc@simon-Leopard-Extreme:ExamplesC$ ./examp --query-goal "format('Hi Mom', [])"
GNU Prolog 1.4.4 (64 bits)
Compiled May 15 2017, 21:17:39 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?-

Everything else works perfectly. Have I misunderstood what is supposed to happen or is this a bug?

Regards

Simon Curry


_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog
Reply | Threaded
Open this post in threaded view
|

Re: gprolog extended via C interface ignores command-line interface arguments

Daniel Diaz-3
Hi Simon,

sorry for the late reply.

The top-level is a specific application which its own main() (testing filtering command-line arguments to handle some like --query-goal).
It is not the case of user defined application for which the default main() does not scan the command-line (the user is free to use any command).
Your executable is such an application, only the default main() is used.

To provide an executable with your own C code which behaves like the actual top-level (resulting in an augmented top-level with new functionalities built-in) it is necessary to add a compiler option (e.g. --new-top-level) to force the inclusion of the top-level main().
Do you need this ?

Daniel



Le 02/12/2017 à 07:14, Simon Curry a écrit :

Hi,

I am using:

GNU Prolog 1.4.4 (64 bits)
Compiled Dec  1 2017, 19:56:55 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz

running on a ubuntu machine:

Linux simon-Leopard-Extreme 4.4.0-98-generic #121-Ubuntu SMP Tue Oct 10 14:24:03 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I am extending gprolog with a significant library of crypto functions in C and in general this works very well. The only exception is that the new instance of gprolog, extended with these functions ignores the '--init-goal', '--query-goal' command line arguments. These are useful for running the prolog application from a cron job, for example.

"Fortunately", your own example in /usr/local/gprolog-1.4.4/examples/ExamplesC manifests the same problem, so I need not burden you with all of my code.

For example, when I build your example and compare the operation of the new executable with that of the base gprolog, I get:


sjswc@simon-Leopard-Extreme:ExamplesC$ gprolog --query-goal "format('Hi Mom', [])"
GNU Prolog 1.4.4 (64 bits)
Compiled May 15 2017, 21:17:39 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?- format('Hi Mom', []).
Hi Mom

yes
| ?-

sjswc@simon-Leopard-Extreme:ExamplesC$ ./examp --query-goal "format('Hi Mom', [])"
GNU Prolog 1.4.4 (64 bits)
Compiled May 15 2017, 21:17:39 with gcc
By Daniel Diaz
Copyright (C) 1999-2013 Daniel Diaz
| ?-

Everything else works perfectly. Have I misunderstood what is supposed to happen or is this a bug?

Regards

Simon Curry



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog



_______________________________________________
Bug-prolog mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-prolog