Link to home
Start Free TrialLog in
Avatar of chojan
chojan

asked on

Visual C++ long compile due to big struct

I'm running Visual C++ 2003 and am encountering very long (>1 minute) waits in the compile / Generating code stage of a build.

This is due to a large (120KB) single static structure that I'm including into my source code. The struct is simply made up of about five CStrings. Removing most of the lines from this struct array makes the build process only several seconds.

struct entry {
      unsigned      val;
      CString            a;
      CString            b;
      CString            c;
      CString            d;
      CString            e;
};

// Very large constant array here (~2000 lines)
const entry myclass::m_entries[] = {

{ 0 ,"str1","str2","str3","str4","str5"},
{ 0 ,"abc","str2","str3","str4","str5"},
{ 0 ,"str1","str2","defg","str4","str5"},
{ 0 ,"str1","asdf","str3","erwe","str5"},
...
{ 0 ,"12345","str2","str3","str4","str5"},
};

Why does the build process take so long when this single struct is included? Is there any compile option in the compiler that would correct this?

Lastly, is there a better way to incorporate a relatively large data set in the application? (each string entry is variable length, so the compile will be replacing each with string pointers).

Thanks for any help
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If the strings are all up to a maximum length (eg all less than 10 chars) maybe you ought to consider having them as character arrays instead of CString variables.


Rather than at compile time if you had the contents as a text file and read it at run time?
Avatar of chojan
chojan

ASKER

Even though I was using CString as an aide for the rest of the use for this struct, the initialization using CStrings seems to have caused a significant burden when compared to the old standard char*.

Very glad that this made such a huge difference.

Thanks!