Displaying 2 results from an estimated 2 matches for "changestandardstreamtobinary".
2006 May 23
0
[LLVMdev] Binary output to cout on Windows
...that, you
should change llvm-as.cpp (and all other tools with similar issues) from:
} else { // Specified stdout
// FIXME: cout is not binary!
Out = &std::cout;
}
To:
} else { // Specified stdout
sys::ChangeStandardStreamToBinary(std::cout);
Out = &std::cout;
}
... where "ChangeStandardStreamToBinary" is something that Reid likes. :)
The implementation of ChangeStandardStreamToBinary would do the code above
in the win32 case, and would be a noop in the unix case. This is just one
way to d...
2006 May 23
3
[LLVMdev] Binary output to cout on Windows
The solution (provided in Microsoft's documentation) is to add:
#include <cstdio>
#include <io.h>
#include <fcntl.h>
and run:
int result = _setmode( _fileno(stdin), _O_BINARY );
if( result == -1 )
{ std::cerr<<"Cannot set input mode to binary."<<std::endl; return 1;
}
result = _setmode( _fileno(stdout), _O_BINARY );
if( result == -1 )
{