Skip to content

Commit

Permalink
Added compilation workarounds for MSVC 2015 CTP6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lastique committed Mar 1, 2015
1 parent 7ebfd3b commit 4751a16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions include/boost/log/detail/code_conversion.hpp
Expand Up @@ -35,6 +35,9 @@ namespace aux {
BOOST_LOG_API void code_convert(const wchar_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale());
//! The function converts one string to the character type of another
BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::wstring& str2, std::locale const& loc = std::locale());

// Note: MSVC 2015 (aka VC14) implement char16_t and char32_t types but not codecvt locale facets
#if !defined(BOOST_MSVC)
#if !defined(BOOST_NO_CXX11_CHAR16_T)
//! The function converts one string to the character type of another
BOOST_LOG_API void code_convert(const char16_t* str1, std::size_t len, std::string& str2, std::locale const& loc = std::locale());
Expand All @@ -47,6 +50,7 @@ BOOST_LOG_API void code_convert(const char32_t* str1, std::size_t len, std::stri
//! The function converts one string to the character type of another
BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u32string& str2, std::locale const& loc = std::locale());
#endif
#endif // !defined(BOOST_MSVC)

//! The function converts one string to the character type of another
template< typename CharT, typename SourceTraitsT, typename SourceAllocatorT, typename TargetTraitsT, typename TargetAllocatorT >
Expand Down
5 changes: 5 additions & 0 deletions src/code_conversion.cpp
Expand Up @@ -125,6 +125,9 @@ BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::wstring&
code_convert(str1, str1 + len, str2, std::use_facet< std::codecvt< wchar_t, char, std::mbstate_t > >(loc));
}

// Note: MSVC 2015 (aka VC14) implement char16_t and char32_t types but not codecvt locale facets
#if !defined(BOOST_MSVC)

#if !defined(BOOST_NO_CXX11_CHAR16_T)

//! The function converts one string to the character type of another
Expand Down Expand Up @@ -157,6 +160,8 @@ BOOST_LOG_API void code_convert(const char* str1, std::size_t len, std::u32strin

#endif

#endif // !defined(BOOST_MSVC)

} // namespace aux

BOOST_LOG_CLOSE_NAMESPACE // namespace log
Expand Down
8 changes: 4 additions & 4 deletions src/unhandled_exception_count.cpp
Expand Up @@ -49,8 +49,8 @@ extern "C" void* __cxa_get_globals();
#elif defined(_MSC_VER)
#if _MSC_VER >= 1900
// Visual Studio 14 has redesigned CRT
#define BOOST_LOG_HAS_VCRT_GETPTD
extern "C" void* __vcrt_getptd();
#define BOOST_LOG_HAS_PROCESSING_THROW
extern "C" int* __processing_throw();
#elif _MSC_VER >= 1400
#define BOOST_LOG_HAS_GETPTD
extern "C" void* _getptd();
Expand All @@ -68,9 +68,9 @@ BOOST_LOG_API unsigned int unhandled_exception_count() BOOST_NOEXCEPT
#elif defined(BOOST_LOG_HAS_GETPTD)
// MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}.
return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(_getptd()) + (sizeof(void*) == 8 ? 0x100 : 0x90))); // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100
#elif defined(BOOST_LOG_HAS_VCRT_GETPTD)
#elif defined(BOOST_LOG_HAS_PROCESSING_THROW)
// MSVC specific. Tested on {MSVC 14 CTP}x{x32,x64}.
return *(reinterpret_cast< const unsigned int* >(static_cast< const char* >(__vcrt_getptd()) + (sizeof(void*) == 8 ? 0x38 : 0x1c))); // __vcrt_ptd::_ProcessingThrow, x32 offset - 0x1c, x64 - 0x38
return static_cast< unsigned int >(*__processing_throw());
#else
// Portable implementation. Does not allow to detect multiple nested exceptions.
return static_cast< unsigned int >(std::uncaught_exception());
Expand Down

0 comments on commit 4751a16

Please sign in to comment.