Merge branch 'jlodos-feature/do_not_include_windows.h' into develop

This commit is contained in:
Beman
2017-05-28 16:46:12 -04:00
2 changed files with 20 additions and 17 deletions

View File

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

View File

@ -12,6 +12,8 @@
#ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP #ifndef BOOST_SYSTEM_LOCAL_FREE_ON_EXIT_HPP
#define 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 boost {
namespace system { namespace system {
namespace detail { namespace detail {
@ -24,7 +26,7 @@ public:
~local_free_on_destruction() ~local_free_on_destruction()
{ {
::LocalFree(p_); boost::detail::winapi::LocalFree(p_);
} }
private: private: