next up previous contents index
Next: External Language Interface with Up: External Language Interface with Previous: Example   Contents   Index

Calling Prolog from C

To make Prolog predicates callable from C, one has to replace the main.c file in the emulator with a new file that starts his/her own application. The following function must be executed before any call to Prolog predicates is executed:

       initialize_bprolog(int argc, char *argv[])
In addition, the environment variable BPDIR must be set correctly to be the home directory where B-Prolog is installed. The function initialize_bprolog() allocates all the stacks used in B-Prolog, initializes them, and loads the byte code file bp.out into the program area. There are two possible ways to call B-Prolog.

There is no means to let B-Prolog do backtracking from C. Therefore, if multiple solutions are required, the Prolog program has to return all the solutions through one call.


next up previous contents index
Next: External Language Interface with Up: External Language Interface with Previous: Example   Contents   Index
Neng-Fa Zhou
1999-11-24