[PPL-devel] Print functions in C interface

Hosung Song hosungs at umich.edu
Tue Feb 3 21:26:33 CET 2004


Dear PPL developers,

Greetings. I'm using your PPL library through C interface. I found 
there's no printing functions, so I tried to make my own, and it took me 
couple of hours why my interface didn't work, because my C++ knowledge 
is so old and premature. I think I finally got them correct, and I'd 
like to get some confirmation from you, and hopefully, ask you to 
incorporate the print functions in C interface. I put the following two 
functions at the end of ppl_c.cc, for printing constraints and polyhedra.

------------------------------
#include <iostream>
using namespace std;
using namespace Parma_Polyhedra_Library;
using namespace Parma_Polyhedra_Library::IO_Operators;

int
ppl_print_Constraint(ppl_const_Constraint_t c) try {
   const Constraint& cc = *to_const(c);
   cout << cc << endl;
   return 0;
}
CATCH_ALL

int
ppl_print_Polyhedron(ppl_const_Polyhedron_t ph) try {
   const Polyhedron& phph = *to_const(ph);
   cout << phph << endl;
   return 0;
}
CATCH_ALL
---------------

I didn't know iostream.h was deprecated and I had learned the namespaces 
when I studied C++. So it took a while with lots of compile 
errors/warnings and finally I had this compiled smooth. I also added the 
following to ppl_c.h

---------------------
int ppl_print_Constraint(ppl_const_Constraint_t c);
int ppl_print_Polyhedron(ppl_const_Polyhedron_t ph);
---------------------

Would you confirm if these are correct interfaces for printing? I'm 
wondering if you could improve these so that we can pass a file pointer 
to the functions and redirect the output not just to stdout, but the 
file designated by the file pointer. Thank you very much for your 
invaluable libraries.

Best wishes,

Hosung Song




More information about the PPL-devel mailing list