4 ms·
>release the object file's space in the final executable, and allocate new space for the new object file. Except, the size of the object file will inevitably c
by john_moscow 5y ago
>release the object file's space in the final executable, and allocate new space for the new object file.
Except, the size of the object file will inevitably change. So you are stuck reimplementing a mini-filesystem with logic for allocating/freeing blocks within your final executable, or loading the entire old version in memory, and then producing the new one from scratch. Or, you just keep things in separate files, let the OS handle it for you and go sip some champagne on a New Year's Eve...
Really, C/C++ build logic sucks in many ways, but adding an extra level of complexity to the linking process won't make it better. If you want something cool, check out C++20 modules [0] instead. They will make compilation dramatically faster when used properly.
[0] https://en.cppreference.com/w/cpp/language/modules https://en.cppreference.com/w/cpp/language/modules
- roca 5y ago> Except, the size of the object file will inevitably change. So you are stuck reimplementing a mini-filesystem with logic for allocating/freeing blocks within your final executable, It would be more like malloc/free than a mini-filesystem. I don't think this is likely to be a big problem because the sizes of object files will often not change very much, we know how to implement malloc/free with reasonably low fragmentation, and it doesn't matter much if there is some wasted space in the final executable, when the goal is "we're going to build an executable that runs "pretty fast", for testing purposes".