1% BEGIN LICENSE BLOCK 2% Version: CMPL 1.1 3% 4% The contents of this file are subject to the Cisco-style Mozilla Public 5% License Version 1.1 (the "License"); you may not use this file except 6% in compliance with the License. You may obtain a copy of the License 7% at www.eclipse-clp.org/license. 8% 9% Software distributed under the License is distributed on an "AS IS" 10% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11% the License for the specific language governing rights and limitations 12% under the License. 13% 14% The Original Code is The ECLiPSe Constraint Logic Programming System. 15% The Initial Developer of the Original Code is Cisco Systems, Inc. 16% Portions created by the Initial Developer are 17% Copyright (C) 1993 - 2006 Cisco Systems, Inc. All Rights Reserved. 18% 19% Contributor(s): 20% 21% END LICENSE BLOCK 22% 23% @(#)umsforeign.tex 1.2 93/03/29 24% 25% 26% REL DATE BY DESCRIPTION 27% 29.11.91 Micha Meier 28% 29\chapter{Foreign C Interface} 30%HEVEA\cutdef[1]{section} 31\label{libforeign} 32\index{foreign (library)} 33\index{foreign/3} 34This library (loaded with {\tt :- lib(foreign)}) 35allows to use external functions written 36for Quintus or SICStus Prolog, or to interface 37C functions which are independent of {\eclipse}. 38It accepts the syntax and semantics of the 39predicates \bipref{foreign/3}{../bips/lib/foreign/index.html}, \bipref{load_foreign_files/2}{../bips/lib/foreign/index.html} and \bipref{load_foreign_files/2}{../bips/lib/foreign/index.html} 40of Quintus/SICStus. 41Since their external interface is incompatible with the {\eclipse} one, 42this library generates a C source file which converts the \eclipse 43interface into the foreign one, by defining a new C function 44for every C function defined in the foreign interface. 45Note that this approach uses more C code, but it is still more efficient 46than using a generic procedure to check the argument 47of every external function. 48 49After compiling definitions of the {\bf foreign/3} predicate, 50(the predicate {\bf foreign_file/2} is ignored), 51the predicate {\bf make_simple_interface} has to be called. 52This predicate generates a file {\it interface.c}, which contains 53the auxiliary C definitions. 54This file has to be compiled to obtain the {\it interface.o} file, 55it might also have to be edited to include other {\it .h} files. 56After the file {\it interface.o} has been generated, 57the system is fully compatible with the Quintus/SICStus foreign 58interface, and calling {\bf load_foreign_files/2} will connect 59the external functions with {\eclipse}. 60 61Although it is possible to use this library to interface 62existing independent C functions, its main use is to 63port foreign interface from Quintus or SICStus. 64Please refer to their manuals for the description of the 65foreign interface. 66 67%HEVEA\cutend 68