This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
copying cout and vasprintf
- From: eddy at fericom dot net (Eddy Ilg)
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 10 Dec 2001 22:53:06 +0100
- Subject: copying cout and vasprintf
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