Does not work in C++23 due to conflicts with import std cxx modules

Abierto
#2,969 7 comentarios 1 reacción 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cpp
Área
testing-qa

Línea de trabajo

Comienza con la reproducción reportada de Module.cpp usando C++23 import std con Clang 19 o GCC 15 y, después, inspecciona las inclusiones header-only y amalgamated hpp mencionadas en el issue. Se considera terminado cuando los usuarios pueden deshabilitar los includes de la biblioteca estándar de Catch2 y la reproducción deja de informar de violaciones de ODR.

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

Descripción

Describe the bug
In past discussions, Catch2 devs explained that it's not possible to migrate the project for CXX Modules, because modules cannot export macros, which is correct (https://github.com/catchorg/Catch2/issues/2299). However, even if the user has cxx modules in its code, specially C++23 import std, then it cannot currently interoperate with header only catch2, because it imposes its #include , generating ODR with import std, if compiler is not "smart enough" (which is currently the case and maybe will never be fully solved).
My problem now is that I'm a long time Catch2 user, and I cannot make it work with Clang 19 or GCC 15, because I'm using import std on C++23 and that's incompatible with current Catch2 design (but it's easy to solve!).

Expected behavior
Catch2 should provide some way to disable its #include for STD things, for example, adding an option or macro like "CATCH2_DISABLE_STD_INCLUDE"... so , all #include should be surrounded by this option:

#ifndef CATCH2_DISABLE_STD_INCLUDE
#include <string>
#include <vector>
#endif

Macro name can also be CATCH_USE_STDLIB_MODULE, as in, https://github.com/catchorg/Catch2/issues/2575, but I don't know if Catch2 is interested in really using import std... maybe not! But this proposal here is simpler, it just allows users to choose between its own import std or the current Catch2 #include dependencies.

Reproduction steps
Create some Module.cpp file, with import std, and try to #include catch2, or try to link against it. ODR violations will be reported.

Platform information:

  • OS: Ubuntu Linux
  • Compiler: Clang 19 or GCC 15

Additional context
If necessary, I can do the PR... specially, for the amalgamated hpp file, it would be nice to disable all its header inclusions.

Lenguaje dominante
C++
Estrellas
21.6k
Forks
3.4k
Merge medio
3 d 12 h
PR fusionados (30 d)
5

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 catchorg/Catch2

Todos los issues de catchorg/Catch2

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.