diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index c457e149c1..bc9c2dd1f8 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -9,6 +9,15 @@ */ #pragma once + +// See Issue #5956. This fixes compilation failure with MSVC 17.12 (v14.44) and C++20: +// '_BACKUP_ITERATOR_DEBUG_LEVEL' undeclared when including span header from STL. +#if defined(_MSC_VER) +# ifndef _BACKUP_ITERATOR_DEBUG_LEVEL +# define _BACKUP_ITERATOR_DEBUG_LEVEL 0 +# endif +#endif + #include "detail/class.h" #include "detail/dynamic_raw_ptr_cast_if_possible.h" #include "detail/exception_translation.h"