mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 05:05:11 +00:00
Allow Windows.h min/max to coexist with pybind11 (#1847)
* Protect std::min/max functions from windows.h min/max Removed check for windows min/max
This commit is contained in:
parent
b2c4ff6052
commit
9b3fb05326
@ -995,9 +995,11 @@ public:
|
||||
}
|
||||
|
||||
bool py_err = py_value == (py_type) -1 && PyErr_Occurred();
|
||||
|
||||
// Protect std::numeric_limits::min/max with parentheses
|
||||
if (py_err || (std::is_integral<T>::value && sizeof(py_type) != sizeof(T) &&
|
||||
(py_value < (py_type) std::numeric_limits<T>::min() ||
|
||||
py_value > (py_type) std::numeric_limits<T>::max()))) {
|
||||
(py_value < (py_type) (std::numeric_limits<T>::min)() ||
|
||||
py_value > (py_type) (std::numeric_limits<T>::max)()))) {
|
||||
bool type_error = py_err && PyErr_ExceptionMatches(
|
||||
#if PY_VERSION_HEX < 0x03000000 && !defined(PYPY_VERSION)
|
||||
PyExc_SystemError
|
||||
|
@ -113,10 +113,6 @@
|
||||
#include <frameobject.h>
|
||||
#include <pythread.h>
|
||||
|
||||
#if defined(_WIN32) && (defined(min) || defined(max))
|
||||
# error Macro clash with min and max -- define NOMINMAX when compiling your program on Windows
|
||||
#endif
|
||||
|
||||
#if defined(isalnum)
|
||||
# undef isalnum
|
||||
# undef isalpha
|
||||
|
@ -495,7 +495,7 @@ protected:
|
||||
|
||||
function_call call(func, parent);
|
||||
|
||||
size_t args_to_copy = std::min(pos_args, n_args_in);
|
||||
size_t args_to_copy = (std::min)(pos_args, n_args_in); // Protect std::min with parentheses
|
||||
size_t args_copied = 0;
|
||||
|
||||
// 0. Inject new-style `self` argument
|
||||
|
Loading…
Reference in New Issue
Block a user