Using -mno-cygwin causes different program behavior

Eric Blake
Thu Dec 4 01:42:00 GMT 2008

Hash: SHA1

According to C-Programmer on 12/3/2008 6:29 PM:
> But if I compile using the following command line argument:
> $ gcc -mno-cygwin -o ioProg1 ioProg1.c

Then you are no longer using cygwin, and this is almost more of a question
for the mingw list.

> I find that the DLL being used is msvcrt.dll and the program behaves as if
> the gets( name ); line had come before the printf("What is your name?");
> line. Very strange!
> Any ideas on why this is happening?

Yes.  It's called buffering.  Native Windows apps have no idea that cygwin
emulates pty's with pipes, and blindly assume that all pipes are
non-interactive.  For performance reasons, when talking to a
non-interactive client, all stdio libraries perform block buffering
instead of line buffering when stdout is determined to be non-interactive.
 So, because you are running a native windows app in a cygwin console,
your app doesn't realize that you wanted line buffering, and so you don't
see output until 4k or end of process, even though the printf completed
before the gets.

- --
Don't work too hard, make some time for fun as well!

Eric Blake   
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Mozilla -


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list