问题
In c++20, when enabling modules, each include is supposed to be encapsulated so that the ordering does not matter, and macros does not leak out etc.
Apparently the question if it is possible to precompile multiple headers is yes.
My question now is: How do you do this: That is: How do i first precompile a set of headers and then make the compiler recognize them (all of them) as precompiled headers for my translation unit using c++20 modules, (using linux command line).
I would like to have solution for g++ but if it is only possible with clang, that answer would be ok.
Notice that this question probably is outdated.
回答1:
How to include multiple precompiled headers ... in gcc
There is no way. As the documentation says:
Only one precompiled header can be used in a particular compilation.
(with modules enabled) in gcc
No released version of GCC supports modules at the moment of writing.
It is somewhat unclear how "include precompiled headers" is related to modules exactly, but I'm guessing that you may be interested in the "Using Prebuilt Modules" section of Clang documentation.
来源:https://stackoverflow.com/questions/65236079/how-to-include-multiple-precompiled-headers-in-with-c20-with-modules-enabled