Node:Conversions, Next:Interface Predicates, Previous:Conversion Declarations, Up:Calling C
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.  Note that the term chars below
refers to a list of character codes, rather than to one-char atoms.
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: +chars
C:      char *
Prolog: +string
C:      char *
Prolog: +string(N)
C:      char *
Prolog: +address
C:      void *
void * pointer.
Prolog: +address(TypeName)
C:      TypeName *
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: -chars
C:      char **
char *. 
The returned encoded string will be converted to a Prolog list of
character codes. 
Prolog: -string
C:      char **
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: -string(N)
C:      char *
Prolog: -address
C:      void **
void *. 
The returned value should be an aligned pointer.
Prolog: -address(TypeName)
C:      TypeName **
TypeName *.  The returned value should be an aligned pointer.
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: [-chars]
C:      char *F()
char *.  The returned encoded
string will be converted to a Prolog list of character codes. 
Prolog: [-string]
C:      char *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: [-string(N)]
C:      char *F()
char *.  The first N bytes
of the encoded string (not necessarily NULL-terminated) will be copied
and the copied string will be stripped of trailing blanks.  The stripped
string will be converted to a Prolog atom. C may reuse or destroy the
string buffer during later calls. 
Prolog: [-address]
C:      void *F()
void *.  The returned value
should be an aligned pointer. 
(see Creating Prolog Terms), will be converted to a Prolog integer. 
Prolog: [-address(TypeName)]
C:      TypeName *F()
TypeName *.  The returned
value should be an aligned pointer.
Prolog: [-term]
C:      SP_term_ref F()