setmode again

Walter Bright newshound1 at digitalmars.com
Fri Aug 8 13:08:19 PDT 2008


Brian Myers wrote:
> No, I haven't because I thought that would result in a compiler or
> linker error. What happens is the function is executed at run time,
> but has no effect. I think I have a better idea now thought:
> 
> Check out this C code:
> 
> #include <fcntl.h> #include <io.h> #include <string.h> #include
> <stdio.h>
> 
> void main() { char *tmp = "Test line1\r\ntest line2\n"; 
> _setmode(_fileno(stdout), _O_BINARY); fwrite(tmp, strlen(tmp),
> sizeof(char), stdout); }
> 
> When compiled and linked with MSVC, it works properly. When compiled
> with DMC, it doesn't. Could there be something wrong with the DMC
> CRT? I would suspect the D runtime library is built on the same code,
> and that's why it's not working properly.

Try:
	stdout->_flag &= ~_IOTRAN;
in the C code.



More information about the Digitalmars-d mailing list