Alex Rivera | Logout

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

Asked 2012-05-14T05:13:17.627
24

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 detect why compile time is so long. Somebody suggests pc-lint and I will give a shot. How should I detect unnecessary #include files in a large C++ project? But if there are other tools which analysis compile time and talk about any hints to increase compile speed, let me know. Thanks in advance.

Environment : Microsoft Visual Studio C++ 2008 or 2010.

Edit
Report

1 Answer

3

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
answered 2012-05-14T05:24:03.157

Your Answer