Skip to content

[Feature] Add C++20 modules support #1254

@iTrooz

Description

@iTrooz

Hello !

I'm trying to use CLI11 with C++20 modules, but I'm getting tons of errors when trying to pass a CLI::App through the module's interface. I think they are mostly about the dummy variable in TypeTools.hpp being TU-local due to being constexpr.

Full error log is available here: https://pastebin.com/PJYpZhAV, but it's mostly a spam of this:

/bin/g++   -std=gnu++23 -fmodules-ts -MD -MT CMakeFiles/math_mod.dir/src/math.ixx.o -MF CMakeFiles/math_mod.dir/src/math.ixx.o.d -fmodules-ts -fmodule-mapper=CMakeFiles/math_mod.dir/src/math.ixx.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o CMakeFiles/math_mod.dir/src/math.ixx.o -c /home/itrooz/tmp3/CppModules/src/math.ixx
In file included from /usr/include/CLI/CLI.hpp:26,
                 from /home/itrooz/tmp3/CppModules/src/math.ixx:3:
/usr/include/CLI/TypeTools.hpp:456:6: error: ‘template<class T1, class T2, class T, typename std::enable_if<std::is_same< <template-parameter-1-1>, <template-parameter-1-2> >::value, CLI::detail::enabler>::type <anonymous> > decltype (CLI::detail::to_string(forward<T>(value))) CLI::detail::checked_to_string(T&&)’ exposes TU-local entity ‘CLI::detail::dummy’
  456 | auto checked_to_string(T &&value) -> decltype(to_string(std::forward<T>(value))) {
      |      ^~~~~~~~~~~~~~~~~
/usr/include/CLI/TypeTools.hpp:39:19: note: ‘CLI::detail::dummy’ declared with internal linkage
   39 | constexpr enabler dummy = {};
      |                   ^~~~~

Example program here: https://github.com/iTrooz/CppModules/tree/cli11, compile (with errors) with CC=/bin/gcc CXX=/bin/g++ cmake -G Ninja -B build && (cd build && ninja)

I am using gcc 15.2.1, cmake 4.1.2 and latest CLI11 commit (c992112), on ArchLinux

This problem does not happen on clang, probably because of llvm/llvm-project#112294

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions