Revert the prior change (do not include windows.h). It worked fine with the msvc toolset, testing with the last four VC++ versions. But it failed with GCC version 4.9.3 cygwin64.

This commit is contained in:
Beman
2016-02-23 10:58:27 -05:00
parent b4aa25dc0e
commit 388b3497af
2 changed files with 17 additions and 21 deletions

View File

@ -21,9 +21,7 @@
#include <cstring> // for strerror/strerror_r
# if defined( BOOST_WINDOWS_API )
# include <winerror.h>
# include <boost/detail/winapi/error_handling.hpp>
# include <boost/detail/winapi/character_code_conversion.hpp>
# include <windows.h>
# if !BOOST_PLAT_WINDOWS_RUNTIME
# include <boost/system/detail/local_free_on_destruction.hpp>
# endif
@ -374,12 +372,12 @@ namespace
std::wstring buf(128, wchar_t());
for (;;)
{
boost::detail::winapi::DWORD_ retval = boost::detail::winapi::FormatMessageW(
boost::detail::winapi::FORMAT_MESSAGE_FROM_SYSTEM_ |
boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_,
DWORD retval = ::FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ev,
boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
&buf[0],
buf.size(),
NULL
@ -390,7 +388,7 @@ namespace
buf.resize(retval);
break;
}
else if (boost::detail::winapi::GetLastError() != ERROR_INSUFFICIENT_BUFFER)
else if ( ::GetLastError() != ERROR_INSUFFICIENT_BUFFER )
{
return std::string("Unknown error");
}
@ -401,23 +399,23 @@ namespace
}
int num_chars = (buf.size() + 1) * 2;
boost::detail::winapi::LPSTR_ narrow_buffer = (boost::detail::winapi::LPSTR_)_alloca(num_chars);
if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0)
LPSTR narrow_buffer = (LPSTR)_alloca( num_chars );
if (::WideCharToMultiByte(CP_ACP, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0)
{
return std::string("Unknown error");
}
std::string str( narrow_buffer );
#else
boost::detail::winapi::LPVOID_ lpMsgBuf = 0;
boost::detail::winapi::DWORD_ retval = boost::detail::winapi::FormatMessageA(
boost::detail::winapi::FORMAT_MESSAGE_ALLOCATE_BUFFER_ |
boost::detail::winapi::FORMAT_MESSAGE_FROM_SYSTEM_ |
boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_,
LPVOID lpMsgBuf = 0;
DWORD retval = ::FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
ev,
boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language
(boost::detail::winapi::LPSTR_) &lpMsgBuf,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR) &lpMsgBuf,
0,
NULL
);
@ -425,7 +423,7 @@ namespace
if (retval == 0)
return std::string("Unknown error");
std::string str(static_cast<boost::detail::winapi::LPCSTR_>(lpMsgBuf));
std::string str( static_cast<LPCSTR>(lpMsgBuf) );
# endif
while ( str.size()
&& (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') )

View File

@ -12,8 +12,6 @@
#ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP
#define BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP
#include <boost/detail/winapi/local_memory.hpp>
namespace boost {
namespace system {
namespace detail {
@ -26,7 +24,7 @@ public:
~local_free_on_destruction()
{
boost::detail::winapi::LocalFree(p_);
::LocalFree(p_);
}
private: