From af44da916a7f44065c6c31d8bcae3a14bad3620f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Sat, 22 Feb 2014 16:09:34 -0700 Subject: [PATCH] Fix warnings and errors on VisualStudio 2013 Interestingly, VS2013 with Boost 1.55 exhibited the issues complained about in issue #92, so I was able to provide an appropriate fix. It would appear to be bugs in both compilers, which seems very odd. --- include/chaiscript/dispatchkit/bootstrap.hpp | 6 ++++- .../dispatchkit/proxy_functions_detail.hpp | 24 +++++++++++++++++++ src/main.cpp | 4 ++-- src/reflection.cpp | 7 +++++- src/test_module.cpp | 6 +++++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 787b05c..af2a148 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -279,7 +279,11 @@ namespace chaiscript boost::shared_ptr pf = boost::dynamic_pointer_cast(t_pf); if (pf) { - return pf->get_guard(); + if (pf->get_guard()) { + return true; + } else { + return false; + } } else { return false; } diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index eda5173..dedc44e 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -86,13 +86,20 @@ namespace chaiscript * if any unboxing fails the execution of the function fails and * the bad_boxed_cast is passed up to the caller. */ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4100) +#endif + #ifdef __llvm__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" #endif + template Ret call_func(const boost::function &f, const std::vector ¶ms, const Dynamic_Cast_Conversions & BOOST_PP_IF(n, t_conversions, BOOST_PP_EMPTY)) + #ifdef __llvm__ #pragma clang diagnostic pop #endif @@ -105,19 +112,31 @@ namespace chaiscript } } +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + /** * Used by Proxy_Function_Impl to determine if it is equivalent to another * Proxy_Function_Impl object. This function is primarly used to prevent * registration of two functions with the exact same signatures */ +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4100) +#endif + #ifdef __llvm__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-parameter" #endif + template bool compare_types_cast(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param)), const std::vector & BOOST_PP_IF(n, params, BOOST_PP_EMPTY), const Dynamic_Cast_Conversions &t_conversions) + + #ifdef __llvm__ #pragma clang diagnostic pop #endif @@ -131,6 +150,11 @@ namespace chaiscript return true; } + +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } } } diff --git a/src/main.cpp b/src/main.cpp index 163adbe..1524931 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,7 @@ void *cast_module_symbol(std::string (*t_path)()) std::string default_search_path() { -#ifdef CHAISCRIPT_WINDOWS // force no unicode +#ifdef BOOST_WINDOWS // force no unicode CHAR path[4096]; int size = GetModuleFileNameA(0, path, sizeof(path)-1); @@ -60,8 +60,8 @@ std::string default_search_path() return ""; } - #else + std::string exepath; std::vector buf(2048); diff --git a/src/reflection.cpp b/src/reflection.cpp index 289d253..9271379 100644 --- a/src/reflection.cpp +++ b/src/reflection.cpp @@ -24,7 +24,12 @@ bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf) = boost::dynamic_pointer_cast(t_pf); if (pf) { - return pf->get_parse_tree(); + if (pf->get_parse_tree()) + { + return true; + } else { + return false; + } } else { return false; } diff --git a/src/test_module.cpp b/src/test_module.cpp index 417bb37..796f5ff 100644 --- a/src/test_module.cpp +++ b/src/test_module.cpp @@ -15,6 +15,9 @@ class TestBaseType int val; const int const_val; + + private: + TestBaseType &operator=(const TestBaseType &); }; enum TestEnum @@ -32,6 +35,9 @@ class TestDerivedType : public TestBaseType public: virtual ~TestDerivedType() {} virtual int func() { return 1; } + + private: + TestDerivedType &operator=(const TestDerivedType &); }; std::string hello_world()