Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - fdopen bug
Here is a small C program who does not work when compiled with Digital Mars C/C++ Compiler Version 8.49.4n It does run Ok with VC 6.0 gcc (MingW and Cygwin) Watcom lcc-win32 I think it should work with DMC. --- result execution --- fileno(stdin): 0040A180 0 fileno(stdout): 0040A1A0 1 fileno(stderr): 0040A1C0 2 Assertion failure: 'fp' on line 17 in file '0.c' abnormal program termination --- program --- #include <stdio.h> #include <io.h> #include <fcntl.h> #include <assert.h> #include <stdlib.h> #ifdef __CYGWIN__ #include <unistd.h> #endif int main( ) { FILE *fp; int fd; fprintf( stderr, "fileno(stdin): %p %d\n", stdin, fileno(stdin) ); fprintf( stderr, "fileno(stdout): %p %d\n", stdout, fileno(stdout) ); fprintf( stderr, "fileno(stderr): %p %d\n", stderr, fileno(stderr) ); fd = fileno(stdout); assert(fd!=-1); fp = fdopen(fd,"w"); assert(fp); fprintf(fp, "Ok.\n"); fclose(fp); return 0; } Sep 16 2006
|