[英]Compiling large header files C++
My code is organized as 我的代码组织为
//LARGEHEADER.H
class LARGE {
...
}
//SMALLER.H
#include "LARGEHEADER.H"
class SMALL: protected LARGE {
...
}
//and in each of A.C, B.C, C.C ...
#include "SMALLER.H"
void f() {
...
}
Now LARGEHEADER.H is in the order of 10 MB. 现在,LARGEHEADER.H的大小约为10 MB。 While trying to compile this setup it seems to take up a lot of time and memory and my final executable is close to 90 MB.
在尝试编译此设置时,它似乎占用了大量时间和内存,而我的最终可执行文件接近90 MB。 Please point out to me what I am doing wrong.
请向我指出我做错了什么。 How can I speed up my compilation with this setup.
如何使用此设置加快编译速度。
Thanks for suggesting the solutions of pre-compiled headers. 感谢您提出预编译标头的解决方案。 Pre-compiling headers is an optimization strategy which does not address the root cause of the problem, which is coding style.
预编译头是一种优化策略,无法解决问题的根本原因,即编码样式。 Referring to this article
参考本文
Why does C++ compilation take so long? 为什么C ++编译需要这么长时间?
Including a large header file in multiple source/header files will cause the compilation to blow up (generate debug/symbol info for each includer). 在多个源/头文件中包含一个较大的头文件将导致编译工作破裂(为每个includer生成调试/符号信息)。 I re-organized the code to remove such dependencies.
我重新组织了代码以删除此类依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.