On 28 Jan 2005 07:56:32 -0800,
sabine.hubrig-schaumburg@sungard.de
(bine) wrote:
[color=blue]
>Sorry, I found a lot of old stuff, even kind of flamewars about
>good+bad style whatsoever..
>
>I simply want any hint that works!
>
>I try to migrate older stuff from NT and newer stuff from Linux/AIX to
>run on Windows2003 as well. I use the
>Open Watcom C32 Optimizing Compiler Version 1.3
>Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
>[/color]
Questions about specific compilers and implementations are off-topic
here. The Watcom compiler defaults to fully buffered output, but I
think that fact is misleading you in this case.
[color=blue]
>I simply want some lines to be printed to stdout directly, like a
>simple hello.c consisting of basically
>printf("my text\n");
>
>This is only printed when I call the programm with a redirection
>("hello | tee x" or "hello > x"). The problem is mentioned a lot here
>in older comp.* messages. But all the "soultions" I found+tried didn't
>work as well.
>
>I tried alternatively:
>
>fflush(stdout);[/color]
This should work.[color=blue]
>getch();
>getchar();[/color]
These have no applicability here.[color=blue]
>AFTER the printf, and
>
>setvbuf(stdout,NULL,_IONBF,0);[/color]
This should work if used *before* the first I/O to stdout.[color=blue]
>BEFORE that line
>
>and even
>fprintf(stderr,"my text\n");
>because I read somewhere stderr would never be buffered...?[/color]
This should work.[color=blue]
>
>So if there is someone with the patience to explain what to do I could
>stick to watcom. Otherwise I'd have to throw it away and look for
>something else...
>[/color]
My suspicion is that you have something wrong in your program, or you
are seeing a phenomenon due to your OS, since the suggested solutions
should have eliminated the Watcom buffering peculiarity. Did you check
the return value of the functions (fflush, setvbuf, printf) that you
used? Post the smallest compilable example which demonstrates the
problem, and we'll take a look at it.
--
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net