quote: Original post by null_pointer
In my stab at building a large lib (20+ modules)
20 is large? I must have about 50 or so
quote:
Move #include "stdafx.h" line from the .cpp files to the header files of the modules, and just #include the class header files in the .cpp files, and you get instant performance...drop! It''s slightly faster (about 1 second) when you change one header, and the change doesn''t affect any other class, but otherwise the thing takes 2 or 3 seconds, per module! :/
You say 2 or 3 seconds per module as if that''s a bad thing I am lucky to beat 15 seconds per module, 30 is more common.
quote: I don''t know if the experts would agree, but putting everything in stdafx.h and letting the compiler juggle which ones to compile first never seems to be worth the trouble of adding in like 2-5 includes for each module to track which classes are dependent on each other.
Well, keeping unnecessary headers out of your files is generally good so that you don''t pollute your namespace, too, but obviously that matters less and less with classes and encapsulation. The other issue is of course performance, but if you get a speedup by precompiling, obviously that benefit is gone too. What happens if you then want to compile on a compiler which can''t handle precompiled headers? Do GCC or EGCS handle them?
quote:
1) Place forward declarations of all classes (except templates, of course) in the stdafx.h.
2) Include the stdafx.h in all .cpp files.
3) In each class header, include only the necessary headers (base classes, library functions, classes used as data members, etc.) to ensure that particular header will compile fine on its own, in any order. (optional)
4) Place the customary #ifdef/#endif compiler directives around the contents of each header.
5) Place this line in each file, just inside of the compiler directives, but before anything else:
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
That''s what I do, and I''ve never had a problem with compile time. Let me know if I''m wrong somewhere though.
With the exception of stages 1 and 2 (I don''t use stdafx.h right now) and stage 5 (redundant if you use stage 4, surely?) then I do exactly what you say above. And it takes 20 minutes or so to compile. No good. I do only have a P233 with 48mb ram, but I''ve heard of slower machines doing much better.