Archived

This topic is now archived and is closed to further replies.

<string> bloating compile time

This topic is 6112 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use std::string all over my code,the down dise is that it bloats my compile time. Is there a way of typedef''ing it declaring it without having to include the string header? Like you can do this: class CFile; If you don''t want to include the file the CFile is in. Many thanks Chris

Share this post


Link to post
Share on other sites
Are you using pre-compilered headers? put #include<string> in StfAfx.h

I've never done a forward reference with a template, lemme know how it works if you fgure it out.

class std::string; ??

Magmai Kai Holmlor
- The disgruntled & disillusioned


Edited by - Magmai Kai Holmlor on March 18, 2001 8:57:14 PM

Share this post


Link to post
Share on other sites
Should be ok to use a forward reference, if you do it properly. Might be a bit of a hassle though.

Check out <iosfwd> to see how they made forward declarations for the iostream classes, and maybe that''ll give you a hint at how to do it for std::strings.

Share this post


Link to post
Share on other sites
I have a more general question along this same subject:
Is there any way to tell what parts of your program are causing the largest compile times? We have several projects here that have grown over the months and now take a significant time to compile; however, we can''t really track down what code is causing it. Any hints?

Share this post


Link to post
Share on other sites
quote:
Original post by Stoffel
I have a more general question along this same subject:
Is there any way to tell what parts of your program are causing the largest compile times? We have several projects here that have grown over the months and now take a significant time to compile; however, we can''t really track down what code is causing it. Any hints?


That''s an interesting idea. VC++ VBscript allows events handling when a build occurs/ends. That might be useful when combined with a custom build step (AddCustomBuildStepToFile).

Let me know if you come up with anything.

Share this post


Link to post
Share on other sites
quote:
Original post by Kylotan
Should be ok to use a forward reference, if you do it properly. Might be a bit of a hassle though.

Check out to see how they made forward declarations for the iostream classes, and maybe that''ll give you a hint at how to do it for std::strings.


You have a solution???

The iosfwd seems to redefine a template class with the traits and allocators and do a typedef of the iostream.

Share this post


Link to post
Share on other sites
class std::string doersn''t work

error C2242: typedef name cannot follow class/struct/union

Stoffel, if your application is broken up in to different libraries each sections compile time can be measured by appending this to your command line for msdev:

/Y3

That''ll give you output that looks like this:

Compiling...
Main Win32.cpp
Application.cpp
Spawn Time 0:02.5
Creating library...
Spawn Time 0:00.0

Application.lib - 0 error(s), 0 warning(s)
Build Time 0:02.8


Kylotan, I had a look in there, your right it is a bit ugly, I''m not sure if I''m up to this task.

Precompiled headers look good and have been getting a good wrap on the Algorithms mailing list recently too. I spent a good hour today trying to get them working however and didn''t get anywhere.

What I did:
1) Create STL.h, STL.cpp
2) added #includes for vector, map, etc, etc,..
3) Added Include for Stl.h in to stl.cpp.
4) Set compiler option for this file to "Create pch though" : stl.h
5) Set project to "use pch through" : stl.h
6) Replace a few #include ''s with #include "Stl.h"

This seems to produce a huge number of errors in files that dont even use stl.h. Is this technique wrong? Did I miss something?

Thanks

Share this post


Link to post
Share on other sites