The following table lists the possible values for the arguments in
the predicate specification of foreign/[2,3]
. The value
declares which conversion between corresponding Prolog argument
and C type will take place.
Prolog: +integer
C: long
long
and passed to the C function.
Prolog: +float
C: double
double
and
passed to the C function.
Prolog: +atom
C: SP_atom
Prolog: +codes
C: char const *
Prolog: +string
C: char const *
Prolog: +address
C: void *
void *
pointer.
Prolog: +address(
TypeName)
C:
TypeName *
*
pointer.
Prolog: +term
C: SP_term_ref
Prolog: -integer
C: long *
long
.
The value returned will be converted to a Prolog integer.
Prolog: -float
C: double *
double
.
The value returned will be converted to a Prolog float.
Prolog: -atom
C: SP_atom *
SP_atom
.
The value returned should be the canonical representation of a
Prolog atom.
Prolog: -codes
C: char const **
char *
.
The returned encoded string will be converted to a Prolog code-list.
Prolog: -string
C: char const **
char *
.
The returned encoded string will be converted to a Prolog atom. Prolog
will copy the string to a safe place, so the memory occupied by the
returned string may be reused during subsequent calls to foreign
code.
Prolog: -address
C: void **
void *
.
Prolog: -address(
TypeName)
C:
TypeName **
*
.
Prolog: -term
C: SP_term_ref
Prolog: [-integer]
C: long
F()
long
. The value returned will be
converted to a Prolog integer.
Prolog: [-float]
C: double
F()
double
. The value returned will
be converted to a Prolog float.
Prolog: [-atom]
C: SP_atom
F()
SP_atom
. The value
returned must be the canonical representation of a Prolog atom.
Prolog: [-codes]
C: char const *
F()
char *
. The returned encoded
string will be converted to a Prolog code-list.
Prolog: [-string]
C: char const *
F()
char *
. The returned encoded
string will be converted to a Prolog atom. Prolog will copy the string
to a safe place, so the memory occupied by the returned string may be
reused during subsequent calls to foreign code.
Prolog: [-address]
C: void *
F()
void *
, which will be converted to a Prolog integer.
Prolog: [-address(
TypeName)]
C:
TypeName *
F()
*
.
Prolog: [-term]
C: SP_term_ref
F()