[modules] Preprocessing requires compiled header unit modules
Boris Kolpackov
boris@codesynthesis.com
Thu Apr 21 04:05:52 GMT 2022
Ben Boeckel <ben.boeckel@kitware.com> writes:
> However, for header unit modules, it runs into a problem that imported
> header units are required to be compiled and available in the mapper
> while scanning for dependencies.
>
> Example code:
>
> ```c++ # use-header.cpp
> module;
>
> import "header-unit.hpp";
>
> int main(int argc, char* argv[]) {
> return good;
> }
> ```
>
> There used to be no need to do this back prior to the modules landing in
> `master`, but I can see this being an oversight in the meantime.
I don't think it is. A header unit (unlike a named module) may export
macros which could affect further dependencies. Consider:
import "header-unit.hpp"; // May or may not export macro FOO.
#ifdef FOO
import "header-unit2.hpp"
#endif
More information about the Gcc
mailing list