Compiler options can be set in three ways: from a global list of options (see set_global_compiler_options/1), from the compilation command (see compile/2 and consult/2), and from a directive in the file to be compiled (see compiler directive compiler_options/1).
+
or -
,
indicating that the option is to be turned on, or off,
respectively. (No prefix turns the option on.) This evaluable
predicate sets the global compiler options in the way indicated.
These options will be used in any subsequent compilation, unless
reset by another call to this predicate, or overridden by options
provided in the compile invocation, or overridden by options in
the file to be compiled.
The following options are currently recognized by the compiler:
#define
, #ifdef
, and
#include
. This option can be specified both as a parameter to
compile/2 and as part of the compiler_options/1 directive inside
the source file. See Appendix A for more details on GPP.
When an #include "file"
statement is encountered,
XSB directs GPP preprocessor to search for the files to include in the
directories $XSB_DIR/emu
and $XSB_DIR/prolog_includes
.
However, additional directories can be added to this search path by
asserting into the predicate xpp_include_dir/1
, which should
be imported from module parse.
Note that when compiling XSB programs, GPP searches the current directory and the directory of the parent file that contains the include-directive last. If you want additional directories to be searched, then the following statements must be executed:
:- import xpp_include_dir/1 from parse. :- assert(xpp_include_dir('some-other-dir')).If you want Gpp to search directories in a different order, xpp_options/1 can be used (see below).
Note: if you assert something into this predicate then you must also retractall(xpp_include_dir(_)) after that or else subsequent Prolog compilations might not work correctly.
XSB predefines the constant XSB_PROLOG, which can be used for conditional compilation. For instance, you can write portable program to run under XSB and and other prologs that support C-style preprocessing and use conditional compilation to account for the differences:
#ifdef XSB_PROLOG XSB-specific stuff #else other Prolog's stuff #endif common stuff
However, as mentioned earlier, XSB lets the user filter programs (except
the programs that belong to XSB distribution) through any preprocessor
the user wants. To this end, one only needs to assert the appropriate
command into the predicate xpp_program
, which should be imported
from module parse. The command should not include the file
name--XSB appends the name of the file to be compiled to the command
supplied by the user. For instance, executing
:- assert(xpp_program('/usr/bin/m4 -E -G')).before calling the compiler will have the effect that the next XSB program passed to the compiler will be first preprocessed by the M4 macro package. Note that the XSB compiler automatically clears out the xpp_program predicate, so there is no need to tidy up each time. But this also means that if you need to compile several programs with a non-standard preprocessor then you must specify that non-standard preprocessor each time the program is compiled.
As mentioned earlier, when XSB invokes Gpp, it uses the option -nocurinc so that Gpp will not search the directory of the parent file. If a particular application requires that the parent file directory must be searched, then this can be accomplished by executing assert(xpp_options('-P -m -nostdinc')).
Note: if you assert something into this predicate then you must also retractall(xpp_options(_)) after that or else subsequent Prolog compilations might not work correctly.
WARNING: Occasionally, the analysis itself may take a long time. As far as we have seen, the analysis times are longer than the rest of the compilation time only when the module contains recursive predicates of arity 10. If the analysis takes an unusually long time (say, more than 4 times as long as the rest of the compilation) you may want to abort and restart compilation without modeinfer.
WARNING: This option was created for compiler debugging and is not intended for general use. There might be cases where compiling a module with these options may cause generation of an incorrect .A and .O file. In such cases, the user can see the SLG-WAM instructions that are generated for a module by compiling the module as usual and then using the -d module.O command-line option of the XSB emulator (see Section 3.5).