The high-level foreign predicate interface was designed to release the programmer from the burden of having to write low-level code to transfer data from XSB to C and vice-versa. Instead, all the user needs to do is to describe each C function and its corresponding Prolog predicates in the .H files. The interface then automatically generates wrappers that translate Prolog terms and structures to proper C types, and vice-versa. These wrappers also check for type-correctness of arguments to the C function; in addition, in Unix-derived systems the wrappers are automatically compiled and loaded along with the foreign predicates in the .c file 2.6.
As with the lower-level foreign interfaces, when predicates are
defined in a foreign module myfile.[cH], the predicates must
be explicitly imported from the module to be used 2.7. For an
example of using the higher level interface, see $XSBDIR/examples/XSB_calling_c/second_foreign.[cH].