How should I detect bottleneck of compile time in a large C++ project?

后端 未结 4 1513
暖寄归人
暖寄归人 2021-02-18 15:41

I want to reduce compile time of a large C++ project. I tried to use precompiled headers, interface and etc. But before I move on, I want to know whether any tool which helps de

4条回答
  •  轮回少年
    2021-02-18 15:57

    I am not aware of any tool for betterment of the compile time, but few manual remedies, I can suggest (consider this as comment):

    1. Have #include guards with every header file, so that multiple inclusions won't make any issues
    2. Reduce member function body, inline function body putting directly into the header files; just have their declarations
    3. Check if there are no unnecessary template function and classes; remember that tempaltes become inline by default. Too much of templates/metaprogramming cause huge compilation time.
    4. If number of #defines are unnecessarily high then they would increase preprocessing stage, which ultimately increases the compilation time

提交回复
热议问题