[BUG]: Compilation failure with MSVC 17.12 (v14.44) and C++20: '_BACKUP_ITERATOR_DEBUG_LEVEL' undeclared

Abierto
#5,956 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cmake, cpp, python

Línea de trabajo

Comienza con pybind11/pybind11.h y el contexto del error de MSVC ; después reproduce la compilación de CMake C++20 descrita para Kratos PR 14105 usando MSVC 14.44. Se considera terminado cuando la compilación afectada se complete sin el error _BACKUP_ITERATOR_DEBUG_LEVEL en el entorno indicado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

triage
Required prerequisites
What version (or hash if on master) of pybind11 are you using?

3.0.1

Problem description

This is a well-structured GitHub issue template you can use. It specifically targets the MSVC 17.12 incompatibility with the iterator debugging macros found in the Kratos core.


GitHub Issue Title:

Compilation failure with MSVC 17.12 (v14.44) and C++20: '_BACKUP_ITERATOR_DEBUG_LEVEL' undeclared


Description

When compiling Kratos Multiphysics, see https://github.com/KratosMultiphysics/Kratos/pull/14105, with the last pybind11 release on Windows using Visual Studio 2022 version 17.12 (MSVC 14.44) with the std:c++20 flag, the build fails in several python binding files due to a macro conflict in the MSVC Standard Library headers.

The error appears to originate from the <span> header in the MSVC STL, which seems unable to resolve the custom _BACKUP_ITERATOR_DEBUG_LEVEL macro used by Kratos to manage iterator debugging states.

Environment
  • OS: Windows 10/11
  • Compiler: MSVC 14.44.35207 (Visual Studio 2022 17.12)
  • C++ Standard: C++20
  • Python version: 3.10.11
  • Build Type: Release
Error Log
C:\Program Files (x86)\...\include\span(179): error C2065: '_BACKUP_ITERATOR_DEBUG_LEVEL' : undeclared identifier
C:\Program Files (x86)\...\include\span(179): note: the template instantiation context (the oldest) is
C:\Program Files (x86)\...\include\span(31): note: during compilation of class template 'std::_Span_iterator'
C:\Program Files (x86)\...\include\span(179): error C3861: '_BACKUP_ITERATOR_DEBUG_LEVEL': identifier not found

Steps to Reproduce
  1. Use Visual Studio 2022 updated to version 17.12.
  2. Configure Kratos with CMake using -DCMAKE_CXX_STANDARD=20.
  3. Attempt to build the Kratos Core.
Potential Workaround

Adding in the header of <pybind11/pybind11.h>:

#if defined(_MSC_VER)
#ifndef _BACKUP_ITERATOR_DEBUG_LEVEL
#define _BACKUP_ITERATOR_DEBUG_LEVEL 0
#endif
#endif
Reproducible example code
(Sorry, but it is a full codebase, so I cannot isolate a snippet)
Is this a regression? Put the last known working version here if it is.

Not a regression

Lenguaje dominante
C++
Estrellas
18k
Forks
2.3k
Merge medio
5 d 7 h
PR fusionados (30 d)
53

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pybind/pybind11

Todos los issues de pybind/pybind11

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.