Skip to content

Commit

Permalink
Disable warning C4275 in MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Gray committed Apr 19, 2019
1 parent abca20b commit d351297
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/pybind11/detail/common.h
Expand Up @@ -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: \
Expand Down
8 changes: 7 additions & 1 deletion include/pybind11/pytypes.h
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit d351297

Please sign in to comment.