[PPL-devel] Last problem (hope!)

Enrico Oliosi enrico.oliosi at students.univr.it
Wed Aug 18 10:37:21 CEST 2004


Hi ppl-gr,
I used the function set_output_function() how you suggest me.
When I use it in a single program like in your tests example
it works correctly, but when I use it in a class I must
declare it static; I used it in a my_print function in order
to print the ph for each comand.

I think that this happens for this reason: since the namespace Variable
have static member when I used the functions of this namespace in
a class (an object which can be initialized more times) I must
declare them static.

The problem is in this class:

class Cmd{

public:

   //ph which I have in each statement
   NNC_Polyhedron ph_in;

   //these are Hashmap the first element is the dimension
   //and the second the variable to print
   static map<dimension_type, string> var_to_print;
   static map<dimension_type, string>::iterator iter;

public:

static void Cmd::new_output_function(ostream& s, const Variable v) {
     iter = var_to_print.find(v.id());
     s << iter->second;
   }

void Cmd::print_constraints(const ConSys& cs, const string& intro, ostream& s){
     using namespace IO_Operators;

     // Save the default output function.
     Variable::Output_Function_Type* p_default_output_function =
       Variable::get_output_function();

     // Install an alternate output function.
     Variable::set_output_function(new_output_function);

     /* Your code of print_constraints() */

     /* Code to restore the default output function. */

     [...]
};

when I compile it the g++ gives me these errors:

/tmp/ccOzbfS7.o(.gnu.linkonce.t._ZN3Cmd19new_output_functionERSoN23Parma_Polyhedra_Library8VariableE+0x24): 
In function `Cmd::new_output_function(std::basic_ostream<char, 
std::char_traits<char> >&, Parma_Polyhedra_Library::Variable)':
: undefined reference to `Cmd::var_to_print'
[...]
: undefined reference to `Cmd::iter'
[...]


Sorry but I am a java-programmer and sometimes when I used c++ I make
some stupid mistake.

All the bests,

 	Enrico.



More information about the PPL-devel mailing list