Next: , Up: User-defined Main Programs Initializing the Prolog Engine

The Prolog Engine is initialized by calling SP_initialize(). This must be done before any interface functions are called, except those marked ‘preinit’ in this manual.

The function will allocate data areas used by Prolog and load the Runtime Library.

It will also initialize command line arguments so that they can be accessed by the argv Prolog flag but it may be preferable to use SP_set_argv() for this. To unload the SICStus emulator, SP_deinitalize() can be called. You may also call SP_force_interactive() before calling SP_initialize(). This will force the I/O built-in predicates to treat the standard streams as a interactive, even if they don't appear to be connected to a terminal or console. Same as the -i option in development systems (see Start).

You may also call SP_set_memalloc_hooks() before calling SP_initialize(). This will define one layer of Prolog's memory manager, in case your application has special requirements.

The SICStus Prolog memory manager has a two-layer structure. The top layer has roughly the same functionality as the standard UNIX functions malloc and free, whereas the bottom layer is an interface to the operating system. It's the bottom layer that can be customized by setting these hooks.

Send feedback on this subject.