Skip to content

Redfinition error with -fcxx-modules #158249

@torarnv

Description

@torarnv

I’m setting up Clang module maps for Qt, and hitting an error when trying to use the module from plain C++. Without -fcxx-modules things build fine:

❯ QT_DIR=/Users/torarne/build/qt/6.x && clang++ -c -std=c++17 -fmodules -F$QT_DIR/qtbase/lib -I$QT_DIR/qtbase/lib/QtCore.framework/Headers main.cpp

but with -fcxx-modules I get a redefinition error that points to the exact same file and line:

❯ QT_DIR=/Users/torarne/build/qt/6.x && clang++ -c -std=c++17 -fmodules -fcxx-modules -F$QT_DIR/qtbase/lib -I$QT_DIR/qtbase/lib/QtCore.framework/Headers main.cpp
In file included from main.cpp:3:
/Users/torarne/build/qt/6.x/qtbase/lib/QtCore.framework/Headers/qstring.h:64:30: error: redefinition of 'treat_as_integral_arg'
   64 | template <typename T> struct treat_as_integral_arg : std::false_type {};
      |                              ^
/Users/torarne/build/qt/6.x/qtbase/lib/QtCore.framework/Headers/qstring.h:64:30: note: previous definition is here
   64 | template <typename T> struct treat_as_integral_arg : std::false_type {};

What’s going on here? 🤔

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:modulesC++20 modules and Clang Header Modules

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions