diff --git a/examples/custom_rtti.cpp b/examples/custom_rtti.cpp index cc8d2a5..6e43d7f 100644 --- a/examples/custom_rtti.cpp +++ b/examples/custom_rtti.cpp @@ -3,6 +3,10 @@ // See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifdef _MSC_VER +#pragma warning(disable: 4312) +#endif + struct Animal { Animal(unsigned type) : type(type) { } diff --git a/examples/deferred_custom_rtti.cpp b/examples/deferred_custom_rtti.cpp index 2c9af72..d60c330 100644 --- a/examples/deferred_custom_rtti.cpp +++ b/examples/deferred_custom_rtti.cpp @@ -3,6 +3,10 @@ // See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) +#ifdef _MSC_VER +#pragma warning(disable: 4312) +#endif + // tag::classes[] struct custom_type_info { static unsigned last; diff --git a/include/boost/openmethod/compiler.hpp b/include/boost/openmethod/compiler.hpp index 351ef30..464344d 100644 --- a/include/boost/openmethod/compiler.hpp +++ b/include/boost/openmethod/compiler.hpp @@ -95,7 +95,7 @@ struct generic_compiler { std::vector used_by_vp; boost::dynamic_bitset<> used_slots; boost::dynamic_bitset<> reserved_slots; - int first_slot = 0; + std::size_t first_slot = 0; std::size_t mark = 0; // temporary mark to detect cycles std::vector vtbl; vptr_type* static_vptr; diff --git a/include/boost/openmethod/registry.hpp b/include/boost/openmethod/registry.hpp index c073c8d..22e9c3a 100644 --- a/include/boost/openmethod/registry.hpp +++ b/include/boost/openmethod/registry.hpp @@ -6,6 +6,7 @@ #include #include +#include #include namespace boost::openmethod { @@ -61,8 +62,18 @@ struct trace : policy { template struct fn { inline static bool trace_enabled = []() { +#ifdef _MSC_VER + char* env; + std::size_t len; + auto result = + _dupenv_s(&env, &len, "BOOST_OPENMETHOD_TRACE") == 0 && env && + len == 2 && *env == '1'; + free(env); + return result; +#else auto env = getenv("BOOST_OPENMETHOD_TRACE"); return env && *env++ == '1' && *env++ == 0; +#endif }(); }; };