Clingo C API
C API for clingo providing high level functions to control grounding and solving.
Classes | Macros | Typedefs | Enumerations | Functions
Basic Data Types and Functions

Detailed Description

Data types and functions used throughout all modules and version information.

For an example, see version.c.

Classes

struct  clingo_location
 Represents a source code location marking its beginnig and end. More...
 

Macros

#define CLINGO_VERSION_MAJOR   5
 Major version number.
 
#define CLINGO_VERSION_MINOR   0
 Minor version number.
 
#define CLINGO_VERSION_REVISION   0
 Revision number.
 
#define CLINGO_VERSION   #CLINGO_VERSION_MAJOR "." #CLINGO_VERSION_MINOR "." #CLINGO_VERSION_REVISION
 String representation of version.
 

Typedefs

typedef int32_t clingo_literal_t
 Signed integer type used for aspif and solver literals.
 
typedef uint32_t clingo_atom_t
 Unsigned integer type used for aspif atoms.
 
typedef uint32_t clingo_id_t
 Unsigned integer type used in various places.
 
typedef int32_t clingo_weight_t
 Signed integer type for weights in sum aggregates and minimize constraints.
 
typedef int clingo_error_t
 Corresponding type to clingo_error.
 
typedef int clingo_warning_t
 Corresponding type to clingo_warning.
 
typedef void clingo_logger_t(clingo_warning_t code, char const *message, void *data)
 Callback to intercept warning messages. More...
 
typedef int clingo_truth_value_t
 Corresponding type to clingo_truth_value.
 
typedef struct clingo_location clingo_location_t
 Represents a source code location marking its beginnig and end. More...
 

Enumerations

enum  clingo_error {
  clingo_error_success = 0, clingo_error_runtime = 1, clingo_error_logic = 2, clingo_error_bad_alloc = 3,
  clingo_error_unknown = 4
}
 Enumeration of error codes. More...
 
enum  clingo_warning {
  clingo_warning_operation_undefined = 0, clingo_warning_runtime_error = 1, clingo_warning_atom_undefined = 2, clingo_warning_file_included = 3,
  clingo_warning_variable_unbounded = 4, clingo_warning_global_variable = 5, clingo_warning_other = 6
}
 Enumeration of warning codes. More...
 
enum  clingo_truth_value { clingo_truth_value_free = 0, clingo_truth_value_true = 1, clingo_truth_value_false = 2 }
 Represents three-valued truth values. More...
 

Functions

char const * clingo_error_string (clingo_error_t code)
 Convert error code into string.
 
clingo_error_t clingo_error_code ()
 Get the last error code set by a clingo API call. More...
 
char const * clingo_error_message ()
 Get the last error message set if an API call fails. More...
 
void clingo_set_error (clingo_error_t code, char const *message)
 Set a custom error code and message in the active thread. More...
 
char const * clingo_warning_string (clingo_warning_t code)
 Convert warning code into string.
 
void clingo_version (int *major, int *minor, int *revision)
 Obtain the clingo version. More...
 

Typedef Documentation

Represents a source code location marking its beginnig and end.

Note
Not all locations refer to physical files. By convention, such locations use a name put in angular brackets as filename.
typedef void clingo_logger_t(clingo_warning_t code, char const *message, void *data)

Callback to intercept warning messages.

Parameters
[in]codeassociated warning code
[in]messagewarning message
[in]datauser data for callback
See also
clingo_control_new()
clingo_parse_term()
clingo_parse_program()

Enumeration Type Documentation

Enumeration of error codes.

Note
Errors can only be recovered from if explicitly mentioned; most functions do not provide strong exception guarantees. This means that in case of errors associated objects cannot be used further. If such an object has a free function, this function can and should still be called.
Enumerator
clingo_error_success 

successful API calls

clingo_error_runtime 

wrong usage of the clingo API or invalid input

clingo_error_logic 

internal error that should not occur in practice

clingo_error_bad_alloc 

memory could not be allocated

clingo_error_unknown 

errors unrelated to clingo

Represents three-valued truth values.

Enumerator
clingo_truth_value_free 

no truth value

clingo_truth_value_true 

true

clingo_truth_value_false 

false

Enumeration of warning codes.

Enumerator
clingo_warning_operation_undefined 

undefined arithmetic operation or weight of aggregate

clingo_warning_runtime_error 

to report multiple errors; a corresponding runtime error is raised later

clingo_warning_atom_undefined 

undefined atom in program

clingo_warning_file_included 

same file included multiple times

clingo_warning_variable_unbounded 

CSP variable with unbounded domain.

clingo_warning_global_variable 

global variable in tuple of aggregate element

clingo_warning_other 

other kinds of warnings

Function Documentation

clingo_error_t clingo_error_code ( )

Get the last error code set by a clingo API call.

Note
Each thread has its own local error code.
Returns
error code
Examples:
ast.c, backend.c, configuration.c, control.c, model.c, propagator.c, solve-async.c, solve-iteratively.c, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.
char const* clingo_error_message ( )

Get the last error message set if an API call fails.

Note
Each thread has its own local error message.
Returns
error message or NULL
Examples:
ast.c, backend.c, configuration.c, control.c, model.c, propagator.c, solve-async.c, solve-iteratively.c, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.
void clingo_set_error ( clingo_error_t  code,
char const *  message 
)

Set a custom error code and message in the active thread.

Parameters
[in]codethe error code
[in]messagethe error message
Examples:
ast.c, backend.c, configuration.c, control.c, model.c, propagator.c, solve-async.c, solve-iteratively.c, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.
void clingo_version ( int *  major,
int *  minor,
int *  revision 
)

Obtain the clingo version.

Parameters
[out]majormajor version number
[out]minorminor version number
[out]revisionrevision number
Examples:
version.c.