From: Mikko Rasa Date: Mon, 9 Jul 2012 14:09:45 +0000 (+0300) Subject: Windows compilation fixes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=651cfe05e867ffdef9028a831add3eca54d19d0d;p=libs%2Fcore.git Windows compilation fixes --- diff --git a/source/core/hash.h b/source/core/hash.h index 1eebcce..bb3de05 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -5,7 +5,7 @@ namespace Msp { -#ifdef WIN32 +#ifdef MSVC typedef __uint64 HashValue64; #else typedef unsigned long long HashValue64; diff --git a/source/io/console.cpp b/source/io/console.cpp index 259f80f..c846604 100644 --- a/source/io/console.cpp +++ b/source/io/console.cpp @@ -14,13 +14,13 @@ using namespace std; namespace { #ifdef WIN32 -DWORD stream_to_sys(Console::Stream stream) +DWORD stream_to_sys(Msp::IO::Console::Stream stream) { switch(stream) { - case INPUT: return STD_INPUT_HANDLE; - case OUTPUT: return STD_OUTPUT_HANDLE; - case ERROR: return STD_ERROR_HANDLE; + case Msp::IO::Console::CIN: return STD_INPUT_HANDLE; + case Msp::IO::Console::COUT: return STD_OUTPUT_HANDLE; + case Msp::IO::Console::CERR: return STD_ERROR_HANDLE; default: throw invalid_argument("stream_to_sys"); } } @@ -37,25 +37,25 @@ namespace IO { Console::Console(Stream s): stream(s) { - mode = (stream==INPUT ? M_READ : M_WRITE); + mode = (stream==CIN ? M_READ : M_WRITE); #ifdef WIN32 *handle = GetStdHandle(stream_to_sys(stream)); #else *handle = stream; - if(stream==INPUT) + if(stream==CIN) tcgetattr(*handle, &orig_attr); #endif - if(stream==INPUT) + if(stream==CIN) set_events(P_INPUT); } Console::~Console() { #ifndef WIN32 - if(stream==INPUT) + if(stream==CIN) tcsetattr(*handle, TCSADRAIN, &orig_attr); #endif } @@ -156,23 +156,23 @@ unsigned Console::do_read(char *buf, unsigned len) Console &Console::instance(Stream s) { - static Console in(INPUT); - static Console out(OUTPUT); - static Console err(ERROR); + static Console in(CIN); + static Console out(COUT); + static Console err(CERR); switch(s) { - case INPUT: return in; - case OUTPUT: return out; - case ERROR: return err; + case CIN: return in; + case COUT: return out; + case CERR: return err; } throw invalid_argument("Console::instance"); } -Console &cin = Console::instance(Console::INPUT); -Console &cout = Console::instance(Console::OUTPUT); -Console &cerr = Console::instance(Console::ERROR); +Console &cin = Console::instance(Console::CIN); +Console &cout = Console::instance(Console::COUT); +Console &cerr = Console::instance(Console::CERR); } // namespace IO } // namespace Msp diff --git a/source/io/console.h b/source/io/console.h index d29ef00..7b7887b 100644 --- a/source/io/console.h +++ b/source/io/console.h @@ -17,9 +17,9 @@ class Console: public EventObject public: enum Stream { - INPUT = 0, - OUTPUT = 1, - ERROR = 2 + CIN = 0, + COUT = 1, + CERR = 2 }; private: diff --git a/source/io/pipe.cpp b/source/io/pipe.cpp index 639743f..0f20698 100644 --- a/source/io/pipe.cpp +++ b/source/io/pipe.cpp @@ -28,7 +28,7 @@ Pipe::Pipe(): if(!write_handle) { unsigned err = GetLastError(); - CloseHandle(*handle[0]); + CloseHandle(*read_handle); throw system_error(format("CreateFile(%s)", name), err); } #else