# Splitting up .cpp files for faster dev build turnaround times?

**URL:** <https://discourse.cataclysmdda.org/t/splitting-up-cpp-files-for-faster-dev-build-turnaround-times/20400>\
**Category:** The Toolbox\
**Created:** [June 16, 2019, 10:54am UTC](https://discourse.cataclysmdda.org/t/splitting-up-cpp-files-for-faster-dev-build-turnaround-times/20400 "2019-06-16T10:54:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tourist](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/tourist/32/6467_2.png) [@tourist](https://discourse.cataclysmdda.org/u/tourist)\
**Post date:** [June 16, 2019, 10:54am UTC](https://discourse.cataclysmdda.org/t/splitting-up-cpp-files-for-faster-dev-build-turnaround-times/20400/1 "2019-06-16T10:54:55Z")

</div>

How’s the mood for splitting big .cpp files into smaller units? Say, for more granularity in compilation which cuts down development build loops, and may help overall build times if it helps parallelize.

So I was hacking on some tileset code. Build times were a bit slow as the whole of cata\_tiles.cpp takes some time to build (which is understandable given its non-trivial nature). I tried extracting the functions I was working on into a new .cpp file and it helped a lot. CMake automatically picks up the new files. The change-build-run loop was a lot tighter. I re-merged the file before commit. I think I’ll be doing this for local development.

I think it might be useful to split some of the bigger .cpp files into subsets. Say, cata\_tiles.h corresponds to cata\_tiles.cpp, cata\_tiles\_subset.cpp, cata\_tiles\_anothersubset.cpp. Or something like this? It still feels a little unclear maybe.

I just wanted to check, yeah, what the general mood or consensus was on splitting .cpp files? Has this been discussed? Might make sense in some cases?

---

<div class="post-metadata">

**Author:** ![mlangsdorf](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/mlangsdorf/32/2462_2.png) [@mlangsdorf](https://discourse.cataclysmdda.org/u/mlangsdorf)\
**Post date:** [June 16, 2019, 3:46pm UTC](https://discourse.cataclysmdda.org/t/splitting-up-cpp-files-for-faster-dev-build-turnaround-times/20400/2 "2019-06-16T15:46:31Z")

</div>

I’m all for it, as long as it makes sense. Splitting a class among multiple files is kind of icky, but I did it in the vehicles code and no one complained too much.
