Using -mno-cygwin causes different program behavior
Thu Dec 4 01:42:00 GMT 2008
-----BEGIN PGP SIGNED MESSAGE-----
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 email@example.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin