Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I've just Googled the same question. The answers seem to glorify the suffering of writing C++ and suggest that the inquirer would perhaps be better off with switching to Java... Sounds like a case of Stockholm syndrome to me.

Anyway, I'm a beginner in C/C++ world and the most convincing solution I've found to use in my personal project is the Single Compilation Unit approach (https://en.wikipedia.org/wiki/Single_Compilation_Unit). It is exemplified in the Handmade Hero github repository (which I'm afraid is available for paying users only). Essentially, the whole program is divided into modules, each within its own single cpp file. The modules are then all included in the SCU, which is the only file passed to the compiler. There can be no circular dependencies between modules (as then, there would be no order of including them in SCU which would work). In HH's case, there seems to be an absolutely minimal number and volume of headers and they only define data structures, never declare functions.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: