10 Interfacing Prolog and C
Introduction
Including and using
gprolog.h
Calling C from Prolog
Introduction
foreign/2
directive
The C function
Input arguments
Output arguments
Input/output arguments
Writing non-deterministic C code
Example: input and output arguments
Example: non-deterministic code
Example: input/output arguments
Manipulating Prolog terms
Introduction
Managing Prolog atoms
Reading Prolog terms
Unifying Prolog terms
Creating Prolog terms
Testing the type of Prolog terms
Comparing Prolog terms
Term processing
Comparing and evaluating arithmetic expressions
Raising Prolog errors
Managing the error context
Instantiation error
Uninstantiation error
Type error
Domain error
Existence error
Permission error
Representation error
Evaluation error
Resource error
Syntax error
System error
Calling Prolog from C
Introduction
Example:
my_call/1
- a
call/1
clone
Example: recovering the list of all operators
Defining a new C
main()
function
Example: asking for ancestors
Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
More about the copyright