delorie.com/djgpp/bugs/show.cgi   search  
Bug 000327

When Created: 11/01/2000 04:28:59
Against DJGPP version: 2.03
By whom: Richard.Curnow@st.com
Abstract: No console output generated at all under Windows NT
I'm using the following installation
 djdev203.zip
 gcc2952b.zip
 bnu2951b.zip

running on Windows NT 4.0 SP6

This is my test prog (check.c)

#include <stdio.h>
#define LT "\n\r"
int main () {
        printf("Line 5" LT);
        printf("Line 4" LT);
        printf("Line 3" LT);
        printf("Line 2" LT);
        printf("Line 1" LT);
        fflush(stdout);
        return 0;
}

In a DOS box I enter
  gcc check.c -o check

(With d:\djgpp\bin at the head of the path)

I get two files 'check' and 'check.exe' produced.  If I now type 'check', I
get a blank line but no other output.  The same thing happens if LT is
changed to either "\n" or "\r\n" as well.

I first saw the problem on a different (larger) program which I had previously
compiled using the same djgpp installation on MSDOS 6.2.  I have no problems with
getting program output when running that other program on MSDOS 6.2, which
makes me think there is a runtime problem under NT.  I get the problem when
running both in NT DOS boxes and full screen NT DOS sessions.

Note added: 12/28/2002 18:05:07
By whom: anddjgpp@ihug.com.au
I have not seen this on NT 4.0 SP3 through SP6 or SP6a (64 and 128 bit).

Note added: 05/06/2003 09:09:26
By whom: djgpp@xenoc.demon.co.uk
I can confirm that this issue exists on Windows 2000 SP3.

Prime suspect: fflush()   (see workaround).

Workaround added: 05/06/2003 09:21:15
By whom: djgpp@xenoc.demon.co.uk
#include <stdio.h>
#define LT "\n\r"

#define FORCE_FLUSH "                                                                                                                                                                    " /* 164 space chars */

int main () {
        printf("Line 5" LT);
        printf("Line 4" LT);
        printf("Line 3" LT);
        printf("Line 2" LT);
        printf("Line 1" LT);
        printf(FORCE_FLUSH);  /* fflush(stdout) doesn't */
        return 0;
}

Tested in a few other scenarios - not found one where this fails.
Often output has one or two extra (blank) lines - but not always...



  webmaster     delorie software   privacy  
  Copyright © 2010   by DJ Delorie     Updated Jul 2010