How to include multiple precompiled headers in with c++20 (with modules enabled) in gcc or clang

China☆狼群 提交于 2020-12-12 05:39:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!