From 9b4f4f84d6429573ef55d08c4a0f605a0a13fb11 Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Mon, 18 Jan 2010 16:34:16 +0000 Subject: [PATCH] MinGW and MSVC fixes. --- samples/werror-test.cpp | 4 +++- src/basicio.cpp | 12 ++++++------ src/error.hpp | 12 ++++++------ src/image.cpp | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/samples/werror-test.cpp b/samples/werror-test.cpp index c9ce4af7..987ac266 100644 --- a/samples/werror-test.cpp +++ b/samples/werror-test.cpp @@ -18,7 +18,9 @@ int main() throw Exiv2::WError(-1, L"WARG1", L"WARG2", L"WARG3"); } catch (const Exiv2::WError& e) { - std::wcout << "Caught WError '" << e.wwhat() << "'\n"; + std::wstring wmsg = e.wwhat(); + std::string msg(wmsg.begin(), wmsg.end()); + std::cout << "Caught WError '" << msg << "'\n"; } return 0; diff --git a/src/basicio.cpp b/src/basicio.cpp index 233df352..cf5d0381 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -502,10 +502,10 @@ namespace Exiv2 { #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { if (fileExists(wpf) && ::_wremove(wpf) != 0) { - throw WError(2, wpf, strError(), "::_wremove"); + throw WError(2, wpf, strError().c_str(), "::_wremove"); } if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) { - throw WError(17, fileIo->wpath(), wpf, strError()); + throw WError(17, fileIo->wpath(), wpf, strError().c_str()); } ::_wremove(fileIo->wpath().c_str()); // Check permissions of new file @@ -998,16 +998,16 @@ namespace Exiv2 { { FileIo file(wpath); if (file.open("rb") != 0) { - throw WError(10, wpath, "rb", strError()); + throw WError(10, wpath, "rb", strError().c_str()); } struct _stat st; if (0 != ::_wstat(wpath.c_str(), &st)) { - throw WError(2, wpath, strError(), "::_wstat"); + throw WError(2, wpath, strError().c_str(), "::_wstat"); } DataBuf buf(st.st_size); long len = file.read(buf.pData_, buf.size_); if (len != buf.size_) { - throw WError(2, wpath, strError(), "FileIo::read"); + throw WError(2, wpath, strError().c_str(), "FileIo::read"); } return buf; } @@ -1027,7 +1027,7 @@ namespace Exiv2 { { FileIo file(wpath); if (file.open("wb") != 0) { - throw WError(10, wpath, "wb", strError()); + throw WError(10, wpath, "wb", strError().c_str()); } return file.write(buf.pData_, buf.size_); } diff --git a/src/error.hpp b/src/error.hpp index 50b54146..80b659d2 100644 --- a/src/error.hpp +++ b/src/error.hpp @@ -94,7 +94,7 @@ namespace Exiv2 { provided to print errors to a stream. */ template - class EXIV2API BasicError : public AnyError { + class BasicError : public AnyError { public: //! @name Creators //@{ @@ -102,13 +102,13 @@ namespace Exiv2 { explicit BasicError(int code); //! Constructor taking an error code and one argument template - EXV_DLLLOCAL BasicError(int code, const A& arg1); + BasicError(int code, const A& arg1); //! Constructor taking an error code and two arguments template - EXV_DLLLOCAL BasicError(int code, const A& arg1, const B& arg2); + BasicError(int code, const A& arg1, const B& arg2); //! Constructor taking an error code and three arguments template - EXV_DLLLOCAL BasicError(int code, const A& arg1, const B& arg2, const C& arg3); + BasicError(int code, const A& arg1, const B& arg2, const C& arg3); //! Virtual destructor. (Needed because of throw()) virtual ~BasicError() throw(); //@} @@ -120,12 +120,12 @@ namespace Exiv2 { @brief Return the error message as a C-string. The pointer returned by what() is valid only as long as the BasicError object exists. */ - virtual const char* what() const throw(); + EXIV2API virtual const char* what() const throw(); /*! @brief Return the error message as a wchar_t-string. The pointer returned by wwhat() is valid only as long as the BasicError object exists. */ - virtual const wchar_t* wwhat() const throw(); + EXIV2API virtual const wchar_t* wwhat() const throw(); //@} private: diff --git a/src/image.cpp b/src/image.cpp index 902e2a22..74e7d81e 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -448,7 +448,7 @@ namespace Exiv2 { std::auto_ptr fileIo(new FileIo(wpath)); // Create or overwrite the file, then close it if (fileIo->open("w+b") != 0) { - throw WError(10, wpath, "w+b", strError()); + throw WError(10, wpath, "w+b", strError().c_str()); } fileIo->close(); BasicIo::AutoPtr io(fileIo);