* freopen() problems
@ 1999-08-12 19:42 Jim Roy
1999-08-12 22:34 ` Mumit Khan
1999-08-31 23:49 ` Jim Roy
0 siblings, 2 replies; 6+ messages in thread
From: Jim Roy @ 1999-08-12 19:42 UTC (permalink / raw)
To: cygwin
The following code works on at least one persons system.
On mine, the freopen() call for one stream wipes out the other.
If I uncomment the second pair, all the reads/writes work fine.
This is a win98 system.
I'v upgraded to 2.95 versions of gcc and mingw-extras
I'm not geting the cygwin.dll by mistake.
I'm using -mwindows, and -mno-cygwin.
I'm at my wits end.
I will be most grateful for ideas about what's left to double check?
----- Begin Included Message -----
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
main (argc, argv)
int argc;
char *argv[];
{
char answer[80];
HANDLE handlein, handleout;
handlein = GetStdHandle (STD_INPUT_HANDLE);
handleout = GetStdHandle (STD_OUTPUT_HANDLE);
if (handleout == INVALID_HANDLE_VALUE)
{
AllocConsole ();
}
freopen ("CONOUT$", "w", stdout);
printf( "Thanks Tor\n" );
freopen ("CONIN$", "r", stdin);
fscanf( stdin, "%s", answer );
/* freopen ("CONOUT$", "w", stdout); */
fprintf( stdout, "%s\n", answer);
/* freopen ("CONIN$", "r", stdin); */
fscanf( stdin, "%s", answer );
fprintf( stdout, "%s\n", answer);
while(1);
}
int _stdcall
WinMain (HANDLE hInstance, HANDLE hPrevInstance, char *lpszCmdLine, int nCmdShow)
{
return main (__argc, __argv);
}
----- End Included Message -----
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: freopen() problems
1999-08-12 19:42 freopen() problems Jim Roy
@ 1999-08-12 22:34 ` Mumit Khan
1999-08-31 23:49 ` Mumit Khan
1999-08-31 23:49 ` Jim Roy
1 sibling, 1 reply; 6+ messages in thread
From: Mumit Khan @ 1999-08-12 22:34 UTC (permalink / raw)
To: Jim Roy; +Cc: cygwin
jim@nga.com (Jim Roy) writes:
>
> The following code works on at least one persons system.
> On mine, the freopen() call for one stream wipes out the other.
> If I uncomment the second pair, all the reads/writes work fine.
>
> This is a win98 system.
> I'v upgraded to 2.95 versions of gcc and mingw-extras
> I'm not geting the cygwin.dll by mistake.
> I'm using -mwindows, and -mno-cygwin.
>
> I'm at my wits end.
> I will be most grateful for ideas about what's left to double check?
Please try the following:
- comment out WinMain
- take out -mwindows
and see what it does.
I'm not sure how stdin/out are attached for windows subsystem apps.
Does it work with Microsoft's compiler?
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* freopen() problems
1999-08-12 19:42 freopen() problems Jim Roy
1999-08-12 22:34 ` Mumit Khan
@ 1999-08-31 23:49 ` Jim Roy
1 sibling, 0 replies; 6+ messages in thread
From: Jim Roy @ 1999-08-31 23:49 UTC (permalink / raw)
To: cygwin
The following code works on at least one persons system.
On mine, the freopen() call for one stream wipes out the other.
If I uncomment the second pair, all the reads/writes work fine.
This is a win98 system.
I'v upgraded to 2.95 versions of gcc and mingw-extras
I'm not geting the cygwin.dll by mistake.
I'm using -mwindows, and -mno-cygwin.
I'm at my wits end.
I will be most grateful for ideas about what's left to double check?
----- Begin Included Message -----
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
main (argc, argv)
int argc;
char *argv[];
{
char answer[80];
HANDLE handlein, handleout;
handlein = GetStdHandle (STD_INPUT_HANDLE);
handleout = GetStdHandle (STD_OUTPUT_HANDLE);
if (handleout == INVALID_HANDLE_VALUE)
{
AllocConsole ();
}
freopen ("CONOUT$", "w", stdout);
printf( "Thanks Tor\n" );
freopen ("CONIN$", "r", stdin);
fscanf( stdin, "%s", answer );
/* freopen ("CONOUT$", "w", stdout); */
fprintf( stdout, "%s\n", answer);
/* freopen ("CONIN$", "r", stdin); */
fscanf( stdin, "%s", answer );
fprintf( stdout, "%s\n", answer);
while(1);
}
int _stdcall
WinMain (HANDLE hInstance, HANDLE hPrevInstance, char *lpszCmdLine, int nCmdShow)
{
return main (__argc, __argv);
}
----- End Included Message -----
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: freopen() problems
1999-08-12 22:34 ` Mumit Khan
@ 1999-08-31 23:49 ` Mumit Khan
0 siblings, 0 replies; 6+ messages in thread
From: Mumit Khan @ 1999-08-31 23:49 UTC (permalink / raw)
To: Jim Roy; +Cc: cygwin
jim@nga.com (Jim Roy) writes:
>
> The following code works on at least one persons system.
> On mine, the freopen() call for one stream wipes out the other.
> If I uncomment the second pair, all the reads/writes work fine.
>
> This is a win98 system.
> I'v upgraded to 2.95 versions of gcc and mingw-extras
> I'm not geting the cygwin.dll by mistake.
> I'm using -mwindows, and -mno-cygwin.
>
> I'm at my wits end.
> I will be most grateful for ideas about what's left to double check?
Please try the following:
- comment out WinMain
- take out -mwindows
and see what it does.
I'm not sure how stdin/out are attached for windows subsystem apps.
Does it work with Microsoft's compiler?
Regards,
Mumit
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: freopen() problems
1999-08-12 22:41 Tor Lillqvist
@ 1999-08-31 23:49 ` Tor Lillqvist
0 siblings, 0 replies; 6+ messages in thread
From: Tor Lillqvist @ 1999-08-31 23:49 UTC (permalink / raw)
To: jim, khan; +Cc: cygwin
> - take out -mwindows
But the point of the code was to figure out a way to get a console window
and be able to do normal stdio to it in a windowing application.
> I'm not sure how stdin/out are attached for windows subsystem apps.
They are invalid if not redirected when starting the app.
> Does it work with Microsoft's compiler?
Yes.
Maybe this is one thing that works differently with crtdll and msvcrt? I use
msvcrt, while jim probably uses crtdll?
--tml
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: freopen() problems
@ 1999-08-12 22:41 Tor Lillqvist
1999-08-31 23:49 ` Tor Lillqvist
0 siblings, 1 reply; 6+ messages in thread
From: Tor Lillqvist @ 1999-08-12 22:41 UTC (permalink / raw)
To: jim, khan; +Cc: cygwin
> - take out -mwindows
But the point of the code was to figure out a way to get a console window
and be able to do normal stdio to it in a windowing application.
> I'm not sure how stdin/out are attached for windows subsystem apps.
They are invalid if not redirected when starting the app.
> Does it work with Microsoft's compiler?
Yes.
Maybe this is one thing that works differently with crtdll and msvcrt? I use
msvcrt, while jim probably uses crtdll?
--tml
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1999-08-31 23:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-12 19:42 freopen() problems Jim Roy
1999-08-12 22:34 ` Mumit Khan
1999-08-31 23:49 ` Mumit Khan
1999-08-31 23:49 ` Jim Roy
1999-08-12 22:41 Tor Lillqvist
1999-08-31 23:49 ` Tor Lillqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).