Previous Up Next

10.2  Including and using gprolog.h

The C code should include gprolog.h which provides a set of C definitions (types, macros, prototypes) associated to the API. Include this files as follows:

#include <gprolog.h>

If the installation has been correctly done nothing else is needed. If the C compiler/preprocessor cannot locate gprolog.h pass the C compiler option required to specify an additional include directory (e.g.-Iinclude_dir) to gplc as follows (section 4.4.3):

% gplc -C -Iinclude_dir ...

The file gprolog.h declares the following C types:

New in GNU Prolog 1.3.1 and backward compatibility issues: in GNU Prolog 1.3.1 the API has been modified to protect namespace. The name of public functions, macros, variables and types are now prefixed with Pl_, PL_ or pl_. All these prefixes should be avoided by the foreign C-code to prevent name clashes. To ensure a backward compatibility, the names used by the old API are available thanks to a set of #define. However, this deprecated API should not be used by recent code. It is also possible to prevent the definition of the compatibility macros using:

#include <gprolog.h>

In addition, gprolog.h defines a set of macros:

Note the above PL_PROLOG_... macros are also accessible via Prolog flags thanks to the built-in predicate current_prolog_flag/2 (section 8.22.2)

Copyright (C) 1999-2018 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright
Previous Up Next