Skip to content

Patching Boost 1.55 for Visual Studio 2013

François Beaune edited this page Mar 18, 2017 · 4 revisions

Making Boost 1.55 compile with Visual Studio 2013

This patch was inspired by this answer on Stack Overflow.

Download the patch and apply it with patch -p0 < boost-155-patch1.patch.

Content of the patch:

--- boost/archive/iterators/transform_width.hpp
+++ boost/archive/iterators/transform_width.hpp
@@ -29,6 +29,7 @@

 #include <boost/iterator/iterator_adaptor.hpp>
 #include <boost/iterator/iterator_traits.hpp>
+#include <algorithm>

 namespace boost { 
 namespace archive {
--- boost/config/compiler/visualc.hpp
+++ boost/config/compiler/visualc.hpp
@@ -180,13 +180,13 @@
 #  define BOOST_NO_CXX11_TRAILING_RESULT_TYPES
 #  define BOOST_NO_CXX11_VARIADIC_TEMPLATES
 #  define BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
+#  define BOOST_NO_CXX11_DECLTYPE_N3276
 #endif
 
 // C++11 features not supported by any versions
 #define BOOST_NO_CXX11_CHAR16_T
 #define BOOST_NO_CXX11_CHAR32_T
 #define BOOST_NO_CXX11_CONSTEXPR
-#define BOOST_NO_CXX11_DECLTYPE_N3276
 #define BOOST_NO_CXX11_NOEXCEPT
 #define BOOST_NO_CXX11_UNICODE_LITERALS
 #define BOOST_NO_SFINAE_EXPR
--- libs/config/test/no_decltype_n3276_fail.cpp
+++ libs/config/test/no_decltype_n3276_fail.cpp
@@ -32,6 +32,6 @@

 int main( int, char *[] )
 {
-   return boost_no_decltype_n3276::test();
+   return boost_no_cxx11_decltype_n3276::test();
 }

--- libs/config/test/no_decltype_n3276_pass.cpp
+++ libs/config/test/no_decltype_n3276_pass.cpp
@@ -27,11 +27,11 @@
 #ifndef BOOST_NO_CXX11_DECLTYPE_N3276
 #include "boost_no_decltype_n3276.ipp"
 #else
-namespace boost_no_decltype_n3276 = empty_boost;
+namespace boost_no_cxx11_decltype_n3276 = empty_boost;
 #endif
 
 int main( int, char *[] )
 {
-   return boost_no_decltype_n3276::test();
+   return boost_no_cxx11_decltype_n3276::test();
 }

Working around a crash on exit in Debug mode

The runtime library of Visual Studio 2013 and earlier has a bug that will cause appleseed to crash when exiting. One of the solution to this problem is to patch Boost according to the instructions below.

The inspiration for this patch comes directly from Boost ticket #7211.

Download the patch and apply it with patch -p0 < boost-155-patch2.patch.

Content of the patch:

--- libs/filesystem/src/windows_file_codecvt.hpp
+++ libs/filesystem/src/windows_file_codecvt.hpp
@@ -26,8 +26,8 @@
     : public std::codecvt< wchar_t, char, std::mbstate_t >  
   {
   public:
-    explicit windows_file_codecvt()
-        : std::codecvt<wchar_t, char, std::mbstate_t>() {}
+    explicit windows_file_codecvt(size_t refs = 0)
+        : std::codecvt<wchar_t, char, std::mbstate_t>(refs) {}
   protected:

     virtual bool do_always_noconv() const throw() { return false; }
--- libs/filesystem/src/path.cpp
+++ libs/filesystem/src/path.cpp
@@ -801,7 +801,7 @@
   inline std::locale default_locale()
   {
     std::locale global_loc = std::locale();
-    std::locale loc(global_loc, new windows_file_codecvt);
+    std::locale loc(global_loc, new windows_file_codecvt(1));
     return loc;
   }

@@ -822,7 +822,7 @@

 #elif defined(BOOST_WINDOWS_API) && !defined(BOOST_FILESYSTEM_STATIC_LINK)

-  std::locale path_locale(std::locale(), new windows_file_codecvt); 
+  std::locale path_locale(std::locale(), new windows_file_codecvt(1)); 

   const std::codecvt<wchar_t, char, std::mbstate_t>*
     codecvt_facet_ptr(&std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t> >

Fixing compilation of OpenImageIO and OpenShadingLanguage

The inspiration for this patch comes directly from Boost ticket #9332.

Download the patch and apply it with patch -p0 < boost-155-patch3.patch.

Content of the patch:

--- boost/intrusive/detail/has_member_function_callable_with.hpp	(revision 86605)
+++ boost/intrusive/detail/has_member_function_callable_with.hpp	(working copy)
@@ -219,10 +219,17 @@
          struct BOOST_PP_CAT(BOOST_PP_CAT(has_member_function_callable_with_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME),_impl)
             <Fun, true>
          {
-            template<class U>
-            static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
-               <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
-
+            #ifdef BOOST_MSVC
+               template<class U>
+               static decltype( boost::move_detail::declval<Fun>().BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME()
+                              , boost_intrusive_has_member_function_callable_with::yes_type())
+                  Test(Fun*);
+            #else
+               template<class U>
+               static BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)
+                  <U> Test(BOOST_PP_CAT(zeroarg_checker_, BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME)<U>*);
+            #endif
+			
             template <class U>
             static boost_intrusive_has_member_function_callable_with::no_type Test(...);
 

Fixing a bug in Boost.Thread's upgradable lock implementation

The inspiration for this patch comes directly from Boost ticket #7720.

Download the patch and apply it with patch -p0 < boost-155-patch4.patch.

Content of the patch:

--- boost/thread/win32/shared_mutex.hpp	2013-03-23 02:48:21.000000000 +0100
+++ boost/thread/win32/shared_mutex.hpp	2016-07-28 13:51:35.433426400 +0200
@@ -733,6 +733,7 @@
                 new_state.upgrade=false;
                 bool const last_reader=!--new_state.shared_count;
 
+                new_state.shared_waiting=0;
                 if(last_reader)
                 {
                     if(new_state.exclusive_waiting)
@@ -740,7 +741,6 @@
                         --new_state.exclusive_waiting;
                         new_state.exclusive_waiting_blocked=false;
                     }
-                    new_state.shared_waiting=0;
                 }
 
                 state_data const current_state=interlocked_compare_exchange(&state,new_state,old_state);
Clone this wiki locally