From d3512971b75d370eedcf74b58332f457517b98d0 Mon Sep 17 00:00:00 2001 From: Walter Gray Date: Fri, 19 Apr 2019 11:19:58 -0700 Subject: [PATCH] Disable warning C4275 in MSVC --- include/pybind11/detail/common.h | 8 ++++++++ include/pybind11/pytypes.h | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 33e765feec..17d22be867 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -654,12 +654,20 @@ using expand_side_effects = bool[]; NAMESPACE_END(detail) /// C++ bindings of builtin Python exceptions +// +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4275) // warning C4275: An exported class was derived from a class that wasn't exported +#endif class PYBIND11_EXPORT builtin_exception : public std::runtime_error { public: using std::runtime_error::runtime_error; /// Set the error using the Python C API virtual void set_error() const = 0; }; +#if defined(_MSC_VER) +# pragma warning(pop) +#endif #define PYBIND11_RUNTIME_EXCEPTION(name, type) \ class PYBIND11_EXPORT name : public builtin_exception { public: \ diff --git a/include/pybind11/pytypes.h b/include/pybind11/pytypes.h index ea5274a9cf..4815defc30 100644 --- a/include/pybind11/pytypes.h +++ b/include/pybind11/pytypes.h @@ -319,6 +319,10 @@ NAMESPACE_END(detail) /// thrown to propagate python-side errors back through C++ which can either be caught manually or /// else falls back to the function dispatcher (which then raises the captured error back to /// python). +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4275) // warning C4275: An exported class was derived from a class that wasn't exported +#endif class PYBIND11_EXPORT error_already_set : public std::runtime_error { public: /// Constructs a new exception from the current Python error indicator, if any. The current @@ -349,7 +353,9 @@ class PYBIND11_EXPORT error_already_set : public std::runtime_error { private: object type, value, trace; }; - +#if defined(_MSC_VER) +# pragma warning(pop) +#endif /** \defgroup python_builtins _ Unless stated otherwise, the following C++ functions behave the same as their Python counterparts.