Clang 17 complains about reading module implicitly, and advices to specify the dependencies explicitly

I am trying to implement modules in my existing projects, but seems I am missing something. Indeed, what works with Clang 16 “does not work” as expected with Clang 17.

With Clang 17, I get this kind of message (here adapted to the sample provided below), as soon as I use module partition:

it is deprecated to read module ‘greeter:hello’ implicitly; it is going to be removed in clang 18; consider to specify the dependencies explicitly

With the following code, I get this message 3 times.

I can get rid of it with -Wno-read-modules-implicitly, but I do not understand why it shows up with Clang 17, as according to this draft, my code should not contain anything considered as deprecated.

Here, the content of each file:

greeter.cppm

export module greeter;
export import :world;
export import :hello;

world.cppm

module;

#include <iostream>
#include <string_view>

export module greeter:world;

namespace greeter
{
export std::string_view world(const std::string_view& n)
  {
    return n;
  }
}

hello.cppm

module;

#include <iostream>
#include <string_view>

export module greeter:hello;
import :world;

namespace greeter
{
  export void hello(const std::string_view& n)
  {
    std::cout << "Hello, " << greeter::world(n) << '!' << '\n';
  }
}

main.cpp

import greeter;

int main ()
{
    greeter::hello("World");
    return 0;
}

It is not about deprecation. For implicit modules the compiler finds the dependency and builds it by itself. For C++20 modules, the community is moving to explicit modules. The user has to explicitly specify all dependencies.

There is -fno-implicit-modules .

For the distinction between implicit and explicit modules, I enjoy reading:

1 Like