AW: [C++-sig] Stdout from c++

Oliver Walczak oliver.walczak at momatec.de
Thu Nov 6 09:28:00 CET 2003


Dear Niall,
If it helps out finding the bug: i use WinXP Professional and Python 2.3.2.
I tried to change my print commands from cout to printf as you said, but in
the idle environment nothing gets on screen. But using the hint of
Nicodemus, PySys_WriteStdout, is exactly what i was looking for and works
fine now.
Thanx for your advice, folks!
Oliver

-----Ursprüngliche Nachricht-----
Von: c++-sig-bounces at python.org [mailto:c++-sig-bounces at python.org] Im
Auftrag von Niall Douglas
Gesendet: Donnerstag, 6. November 2003 01:28
An: c++-sig at python.org
Betreff: Re: [C++-sig] Stdout from c++


On 5 Nov 2003 at 10:42, Stefan Seefeld wrote:

> short answer: get a better OS.

Actually the NT core, assuming he's running that, is as good as any 
Unix in this department. In fact, I'd go so far as to say NT core is 
Unix++ design-wise - it certainly smells of Unix and it's superior to
POSIX in many areas.

> long answer: if the OS has the concept of an output stream, and its
>               (buggy) std::cout implementation doesn't connect to it,
>               write your own streambuf that writes to this output
>               stream, then redirect std::cout to use your streambuf.

NT uses the concept of multiple consoles attached to a process. If 
you link using /SUBSYSTEM:CONSOLE, linked in CRT code creates a 
console for you, attachs stdin/stdout/stderr of the CRT library to it 
and opens it.

IDLE should redirect stdin/stdout/stderr to its own window. Therefore 
printf() should work fine. My code uses printf and it all appears in 
the IDLE window perfectly. Hence I really don't see why cout isn't 
working as intended I'm afraid. I'm running Win2k and Win9x may vary 
significantly in this area. However, if you're developing on Win9x, 
then you're mad plain and simple ;)

Cheers,
Niall









More information about the Cplusplus-sig mailing list