I have a plethora of .h/.cpp
files with various classes. From files with tools to files with classes for every type of ‘problem’ the project needs to handle. This is an ever growing list.
I also have several projects that rely on large parts of the same code (shared folder), and still have quite unique features and approaches to problems.
Many many years ago, using a very old version of the c++ Builder IDE, I organized all these files (both .h and .cpp) in special ‘container’ .h/.cpp
files that only linked to them (#include
). For instance GUITools.h/.cpp links to a bunch of files, EngineTools.h/.cpp, links to a bunch of files and so forth (you get what I mean).
Latter files were then the only files I added to the projects. So GUIools.obj, EngineTools.obj etc would be built.
This meant I could easily create a new set of files/classes for a new ‘problem’ and simply add those (#include
) to one .h/.cpp file set and build with this change/addition in all projects.
Making, Building, debugging, tracing into etc. all worked very smoothly in every project and I could easily work on any project and make improvements / fixes in shared code when necessary.
Things worked nicely for a long time, so it was not on the list of things to change or improve on. PS. I also stuck with a particular version of the IDE for a long time.
I now use recent iterations of the IDE / toolset and keep up to date. Contrary to expectations, coding is less fun these days. I find myself Building rather than Making because the IDE / toolset can’t figure out which is which. Showing the contents of variables during debugging often fails because the debugger can’t figure out the variables type. Fancy features like underlining errors don’t work properly, searching issues etc.
The projects build nicely and work stable as ever, but working on them is way less fun these days.
So, I have to change my ways and before I start and overhaul I need to understand what is possible and what is not and I’m also curious if other people have similar approaches or not at all.
I was hoping there is a way to replace those 5/6 ‘container’ aka added-to-each-project .h/.cpp files with other type files that have the same effect but which tell the IDE the files in them are part of the project (so that they are all built in their own obj files etc.). Make would then be lightning fast again (and work, I hope) Or a pragma of sorts ? I really don’t know.
If the prevailing wisdom will be to simply add the individual files to the project(s) each time then that is what I will do (and I will organize myself that way).
I just wonder if there is not a better way to share the code (an not use libs because that’s even more projects and means switching between projects to add/fix something in the libs etc)
Your constructive thoughts appreciated.