copying cout and vasprintf

Eddy Ilg eddy@fericom.net
Mon Dec 10 13:53:00 GMT 2001


Hi gcc gurus,

I want to output log information from my program to either cout or a file. I want it somewhat like this; 

ostream log_stream;

if (output_stout) {
  log_stream=cout;
} else if (output_file) {
  log_stream=ofstream(log_file);
}

By just trying log_stream=cout; I get this though:
/usr/include/g++/streambuf.h:128: `ios::ios(const ios &)' is private
log.cc:16: within this context

How can I do something like the above?

Another question: I want to use vasprintf(). This does not seem to be ANSI. I tried the following:
#define __USE_GNU
#include <stdio.h>
#include <stdlib.h>

void foo() 
{
  vasprintf(..)
}

g++ tells me that vasprintf is not defined. Do I have to use another preprocessor define that __USE_GNU?


Thanks a lot 


Eddy



More information about the Gcc-help mailing list