SP_initialize()
[macro]#include <sicstus/sicstus.h> int SP_initialize(int argc, char **argv, SP_options *options);
Initializes the Prolog engine.
argv
vector.
prolog_flag(argv,X)
.
This argument is copied by SP_initialize()
so it can be discarded
by the caller. May be passed as NULL
if argc
is zero.
Each entry should be an encoded string, i.e. encoded using
‘UTF-8’. This may not be the encoding used by the operating
system when invoking main()
. A better alternative is to pass
zero for argc
, NULL for argv
and use
SP_set_argv()
to pass the argv
entries.
NULL
.
An option block can be initialized with
SP_OPTIONS_STATIC_INITIALIZER
and its options
field set
to point to a SP_option
array. Each SP_option
is a typed
value. Currently the only type is
SP_option_type_system_property
, for setting initial system
properties (see System Properties and Environment Variables).
To pass the system properties foo
and bar
, with values true
and hello
, respectively, you would do something like this
... int res; SP_options opts = SP_OPTIONS_STATIC_INITIALIZER; SP_option props[2]; opts.noptions = 0; opts.options = &props; props[opts.noptions].type = SP_option_type_system_property; props[opts.noptions].u.prop.key = "foo"; props[opts.noptions].u.prop.value = "true"; opts.noptions++; props[opts.noptions].type = SP_option_type_system_property; props[opts.noptions].u.prop.key = "bar"; props[opts.noptions].u.prop.value = "hello"; opts.noptions++; res = SP_initialize(argv, argc, &opts); if (res != SP_SUCCESS) { ... /* error handling */ } ...
SP_SUCCESS
if initialization was successful.
If initialization was successful, further calls to
SP_initialize()
will be no-ops (and return SP_SUCCESS
).
This must be done before any interface functions are called, except
those annotated as [preinit].
The function will allocate data
areas used by Prolog, initialize command line arguments so that they
can be accessed by the argv
Prolog flag, and load the Runtime
Library.
Initializing the Prolog Engine.