Should templates be included in pch files?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I thought that including template headers such as <vector> in the pch is not
useful.
Templates can’t be compiled without the template arguments so there is no
way to pre compile them.

Is this true?

Also, it seems that this could actually be bad since it will significantly
increase the size of the pch file which I would think could slow the
compilation processes due to the additional memory overhead.

Am I correct?
 
Scythen said:
I thought that including template headers such as <vector> in the pch
is not useful.
Templates can't be compiled without the template arguments so there
is no way to pre compile them.

Is this true?

Also, it seems that this could actually be bad since it will
significantly increase the size of the pch file which I would think
could slow the compilation processes due to the additional memory
overhead.

Am I correct?

You can put anything you want in the headers that are used to build the .pch
file, including templates.

Think of the PCH file as "Pre Parsed Header" instead of "Pre Compiled
Header" and it'll make perfect sense. The PCH file is really nothing more
than a dump of the compiler front-end's heap after parsing all of the text
in the "pre compiled" headers.

-cd
 
Ok, that makes sense.

But even so, would template files not greatly increase the amount of data in
the PCH. More so than non template code?

I’m trying to figure out what is making a particular project have very long
compile times and also get random "Fatal Error C1055: compiler limit : out of
keys" errors.

I thought I was on to something when I found that the PCH is over 60 Mb in
size but maybe not.
 
Scythen said:
Ok, that makes sense.

But even so, would template files not greatly increase the amount of
data in the PCH. More so than non template code?

Perhaps. Perhaps not. I wouldn't think templates should be any more space
consuming in the front-end than non-template code of the same size and
complexity.
I'm trying to figure out what is making a particular project have
very long compile times and also get random "Fatal Error C1055:
compiler limit : out of keys" errors.

very long compile times are usually due to deep recursion during template
instantiation.

On the C1055 error, MSDN has this to say:

compiler limit : out of keys

The source file contains too many symbols. The compiler ran out of hash keys
for the symbol table.

Possible solutions

Split the source file into smaller files.
Eliminate unnecessary header files.
Reuse temporary and global variables instead of creating new ones
I thought I was on to something when I found that the PCH is over 60
Mb in size but maybe not.

That's large, but not enormous.

-cd
 
Back
Top