next up previous contents index
Next: 2.1 Foreign Language Modules Up: The XSB System Version Previous: 1.17.3 Ordered Sets   Contents   Index


2. Foreign Language Interface

When XSB is used to build real-world systems, a foreign-language interface may be necessary to:

XSB has both a high-level and the low-level interface to C. The low-level interface is much more flexible, but it requires greater attention to details of how the data is passed between XSB and C. To connect XSB to a C program using the high-level interface requires very little work, but the program must be used ``as is'' and it must take the input and produce the output supported by this high-level interface. Before describing the interfaces themselves, we first describe aspects common to both the lower- and higher-level foreign language interfaces.

The foreign language interface can also support C++ programs. Since XSB is written in C, the interface functions in the foreign C++ module must have the declaration extern ``C'', and a separate compiler option (e.g. specifying g++ rather than gcc) may need to be given to ensure proper linkage, inclusion of C++ libraries, etc. In addition, on certain platforms compilation may need to be done externally to XSB - see the xasp 1package for a example of using the foreign language interface with C++ files. For the rest of this chapter, we restrict our attention to foreign predicates written in C.



Subsections
next up previous contents index
Next: 2.1 Foreign Language Modules Up: The XSB System Version Previous: 1.17.3 Ordered Sets   Contents   Index
Terrance Swift 2007-10-06