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
Who is Participating?
jkrConnect With a Mentor Commented:
I don't really see a reason why to use a CString here - does using

struct entry {
      unsigned      val;
      char*            a;
      char*            b;
      char*            c;
      char*            d;
      char*            e;

speed up compilation?
AndyAinscowFreelance programmer / ConsultantCommented:
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?
chojanAuthor Commented:
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.