Open output file correctly. This is extremely important for

windows-based hosts, where files are opened in text mode by default.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44533 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anton Korobeynikov 2007-12-03 14:28:26 +00:00
parent 31d43183a4
commit 037dd942c9

View File

@ -36,7 +36,7 @@ int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) {
// non-GCC. Some C++ stdlibs even have ofstream::ofstream(int fd).
int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int FileHandle) {
__gnu_cxx::stdio_filebuf<char> Buffer(FileHandle, std::ios_base::out);
std::ostream OS(&Buffer);
std::ostream OS(&Buffer, std::ios::out | std::ios::trunc | std::ios::binary);
if (!OS.fail())
WriteBitcodeToFile(unwrap(M), OS);