std* streams in MSVC
Saulius Krasuckas
saulius2 at ar.fi.lt
Thu Jul 21 02:33:23 CDT 2005
I am testing code:
| #include <stdio.h>
|
| void main( void )
| {
| printf( "The file handle for stdin is %p %d\n", stdin, _fileno( stdin ));
| printf( "The file handle for stdout is %p %d\n", stdout, _fileno( stdout ));
| printf( "The file handle for stderr is %p %d\n", stderr, _fileno( stderr ));
| }
I link with no libraries and get following output:
| The file handle for stdin is 00424A30 0
| The file handle for stdout is 00424A50 1
| The file handle for stderr is 00424A70 2
If I link with msvcrtd.lib, then output is:
| The file handle for stdin is 004150B0 270578480
| The file handle for stdout is 004150D0 270608264
| The file handle for stderr is 004150F0 0
And this I get with msvcrt.lib:
| The file handle for stdin is 004150B0 2013313950
| The file handle for stdout is 004150D0 2013328746
| The file handle for stderr is 004150F0 0
Calls to freopen(), fprintf(), setvbuf() using any std* stream throws an
exception in last two cases (msvcrtd.lib and msvcrt.lib). I guess
pointers are left uninitialized. Anybody knows why and how to make this
code work in all three cases?
More information about the wine-devel
mailing list