libppl_c man page
libppl_c — the C interface of the Parma Polyhedra Library
cc file.c -lppl
This is a short overview on how to use the Parma Polyhedra Library (PPL) in your C programs on Unix-like operating systems. Note that the PPL has interfaces also for C++, Java, OCaml and a number of Prolog systems: look elsewhere for documentation on those. Note also that the present document does not describe the library functionality, its classes or its methods and functions: see The Parma Polyhedra Library User's Manual (version 1.2) and The Parma Polyhedra Library C Language Interface User's Manual (version 1.2) for this kind of information.
Including the Header File
The C interface of the PPL has only one header file, named ppl_c.h. So your program should contain a directive of the form
Of course, you must make sure you installed the PPL in a place where the compiler can find it, either by itself or with the help of a suitable -Idir command line option (see the file INSTALL for information on how to configure the library so that it is installed in the place of your choice).
Initializing and Finalizing the Library
In order to initialize the Parma Polyhedra Library you must call the function
before using any of its functionalities. It is also a good norm to call the function
when you are done with the library.
Using the Library
Keeping in mind that there is no substitute for a careful reading of The Parma Polyhedra Library User's Manual (version 1.2) and The Parma Polyhedra Library C Language Interface User's Manual (version 1.2) you can find examples of use in the directories interfaces/C/tests and demos/ppl_lpsol of the source distribution.
Linking with the Library
Linking with the C interface of the Parma Polyhedra Library is best done using the C compiler itself: usually, specifying the -lppl_c command line option is enough. In fact, if you use a shared version of the library, this automatically records the dependency from the PPL core and the GMP libraries, something that the linker ought to deal with gracefully. Otherwise you will have to add -lppl -lgmpxx -lgmp to the command line. Things are more complex if you installed the PPL into some nonstandard place. In this case you will have to use the -Ldir option and, if you use a shared version of the library, possible take further steps: see the documentation of your system for more information on this subject (the Program Library HOWTO is especially valuable for GNU/Linux users).
All the PPL C interface functions return an int: a negative value means that an error occurred. See The Parma Polyhedra Library C Language Interface User's Manual (version 1.2) for the error codes.
Implementing Memory-Guarded Computations
One of the interesting features of the Parma Polyhedra Library is the possibility to implement memory-guarded computations. The idea is that you can limit the amount of virtual memory available to the process, launch a PPL computation, and be ready to be returned a PPL_ERROR_OUT_OF_MEMORY error code. You can then take the appropriate corrective measures (e.g., simplify the polyhedra and/or select less precise though less complex algorithms), and restart the computation. In order to do that, you should define alternative memory allocation functions for GMP that throw std::bad_alloc upon memory exhaustion. See libppl(3) for instructions on how to do that.
Using Native Floating Point Numbers
At initialization time, the Parma Polyhedra Library sets the FPU rounding mode in a way that allows its floating-point-based computations to be conservative (i.e., possibly approximated but correct) and reasonably efficient. In case your application itself uses native floating point numbers and relies on a particular rounding mode (if you are in doubt, assume that it does rely on round-to-nearest to be in effect), you should use the function
after the PPL initialization and before using native floating point numbers in the application. If your application does not use any floating-point-based PPL abstraction, no further measure should be taken. Otherwise, it is imperative to call the function
before invoking any PPL interface related to such abstractions.
Roberto Bagnara, Patricia M. Hill, and Enea Zaffanella. The Parma Polyhedra Library User's Manual (version 1.2), available (in several formats) at http://bugseng.com/products/ppl/ .
Roberto Bagnara, Patricia M. Hill, and Enea Zaffanella. The Parma Polyhedra Library C Language Interface User's Manual (version 1.2), available (in several formats) at http://bugseng.com/products/ppl/ .
David A. Wheeler. Program Library HOWTO, available (in several formats) at http://www.dwheeler.com/program-library/ .
The latest version of the Parma Polyhedra Library and all the documentation is available at http://bugseng.com/products/ppl/ .
See the file CREDITS in the source distribution or use the command ppl-config --credits for a list of contributors.
Report bugs to <firstname.lastname@example.org>.
Copyright and No Warranty
Copyright (C) 2001-2010 Roberto Bagnara <email@example.com> Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
This is free software; see the file COPYING in the source distribution or use the command ppl-config --copying to obtain the copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.