Specifying the Argument Passing Interface: extern/1

An extern/1 declaration has the form

     :- extern(+CallSpecification)

CallSpecification is a Prolog term specifying how calls from C will pass arguments to and receive arguments from the Prolog predicate. Handling arguments passed from other languages is discussed in fli-ffp-ppl.

CallSpecification is of the form:

     PredicateName(ArgSpec, ArgSpec, ...)

where PredicateName is the name of the Prolog predicate and each ArgSpec is an argument specification for the corresponding argument of the predicate. ArgSpec must be one of the following list

     +integer +float +single +double +atom +string +term +address(T)
     -integer -float -single -double -atom -string -term -address(T)

where T is a foreign type name. The argument type address can always be used instead of address(T).

Argument specifications used when declaring Prolog predicates callable from C are equivalent to those used when specifying an interface for C functions that are to be callable from Prolog.

Here are some example extern/1 declarations:


     :- extern(write(+integer)).
     :- extern(call(+term)).
     :- extern(my_proc(+atom,+integer,-term,-integer)).