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_weighted_literal
 A Literal with an associated weight. More...
 
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   5
 Minor version number.
 
#define CLINGO_VERSION_REVISION   1
 Revision number.
 
#define CLINGO_VERSION   "5.5.1"
 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 struct clingo_weighted_literal clingo_weighted_literal_t
 A Literal with an associated weight.
 
typedef int clingo_error_t
 Corresponding type to clingo_error_e.
 
typedef int clingo_warning_t
 Corresponding type to clingo_warning_e.
 
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_e.
 
typedef struct clingo_location clingo_location_t
 Represents a source code location marking its beginnig and end. More...
 

Enumerations

enum  clingo_error_e {
  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_e {
  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_e { clingo_truth_value_free = 0, clingo_truth_value_true = 1, clingo_truth_value_false = 2 }
 Represents three-valued truth values. More...
 

Functions

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

Typedef Documentation

◆ clingo_location_t

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. The string members of a location object are internalized and valid for the duration of the process.

◆ clingo_logger_t

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

◆ clingo_error_e

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 

errors only detectable at runtime like invalid input

clingo_error_logic 

wrong usage of the clingo API

clingo_error_bad_alloc 

memory could not be allocated

clingo_error_unknown 

errors unrelated to clingo

◆ clingo_truth_value_e

Represents three-valued truth values.

Enumerator
clingo_truth_value_free 

no truth value

clingo_truth_value_true 

true

clingo_truth_value_false 

false

◆ clingo_warning_e

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_code()

CLINGO_VISIBILITY_DEFAULT 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, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.

◆ clingo_error_message()

CLINGO_VISIBILITY_DEFAULT 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, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.

◆ clingo_set_error()

CLINGO_VISIBILITY_DEFAULT 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, statistics.c, symbol.c, symbolic-atoms.c, and theory-atoms.c.

◆ clingo_version()

CLINGO_VISIBILITY_DEFAULT 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.