2

Possible Duplicate:
#include all .cpp files into a single compilation unit?

I'm working on a project in MSVS where most implementation files (.cpp) are excluded from the build and included in a single source file that is compiled.

//a.cpp
#include "b.cpp"
#include "c.cpp"
//and so on...

And since b.cpp and c.cpp aren't compiled by themselves, this is OK.

I know this is not standard practice, I know the pitfalls and I probably wouldn't do this (unless of course someone comes up with a good reason).

So the question is - what's the use of this technique? Does it make compilation faster (also consider a distributed compilation environment)?

Community
  • 1
  • 1
Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625

2 Answers2

3

This is called a unity build.

It's supposed to speed up compilation of the source code.

See a related question here that provides more details: The benefits / disadvantages of unity builds?

Community
  • 1
  • 1
3

The other point can be that some implementation files can be autogenerated. It is much easier to autogenerate an entire file than dealing with changes injection into the existing code. Like partial classes in C#.

Sergey K.
  • 24,894
  • 13
  • 106
  • 174