-2

I asked a question about global variables and one of the answers raised another question which is what is the risk of very large cpp file?

Is the concern here is the maintainability of the program or something else?

My original question

Community
  • 1
  • 1
WhatIf
  • 653
  • 2
  • 8
  • 18
  • How large is large? I've seen a file that is so big, it takes 72 hours to compile and link the executable - it was just one file. It is not just maintainability: the build time takes a hit too. – cup Oct 16 '15 at 18:39

2 Answers2

2

Only maintainability. There is no compilation issues, as it is common for compilers to combine all #include files into a translation unit and then compile that. Thus each .cpp file winds up being many times larger than the input anyway, before moving on to later stages of compilation.

Tino Didriksen
  • 2,215
  • 18
  • 21
0

For a single programmer working on his own program, when size become an issue is a personal choice. For a team of programmers at some company, having some reasonable number of C++ files for an application allows each team member to work on a separate file in parallel. Although there are tool sets that can merge separate edits made to the same source file(s), dealing with potential conflicts (someone has to check and/or fix the conflicts), is an issue.

rcgldr
  • 27,407
  • 3
  • 36
  • 61