Hi @DrN. The way to share code between Arduino projects is libraries. So you should install the files as a library by putting them in a folder under the libraries subfolder of your sketchbook folder.
If you don't know the location of your sketchbook folder, select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus and note the path shown in the "Sketchbook location" preference.
What do you mean by the "arduino tree"? Do you mean installing them as libraries in your sketchbook as I recommend?
I'll address your excuses for not wanting to do that based on the assumption that is what you mean:
That is irrelevant. There is no need to release the code. I'm not talking about submitting the libraries to the Arduino Library Manager.
You only need to manually copy the files to a folder under the libraries subfolder of the sketchbook folder.
That is not a strong argument against installing them as a library. It is very common for us to install a library that will only be used for a single project.
If you follow best practices when writing your code that won't be a serious problem. Just make sure to use a distinctive name for the library and then use that name in the header files and classes/namespaces. There won't be any problem with name collisions of even commonly named objects within that scope.
This will be important once the time comes for you to publish the code anyway.
That won't be necessary. Updating or replacing the Arduino software doesn't affect your sketchbook contents.
You would need to copy the files to the new computer regardless.
When it comes to code in .cpp files, there is no reasonable way to do it if you are using Arduino IDE. However, if you are using the official command line tool provided by Arduino: Arduino CLI, then it is possible to specify additional paths to individual libraries via the --library flag, or the path of an additional folder containing a collection of libraries via the --libraries flag of the arduino-cli compile command.
You can learn how to use that command from the reference here:
https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_compile/
The easiest way will be to use a dedicated sketchbook folder for your project, which will contain the libraries for that project. Although not required, it will be convenient to also store the project sketches in that folder.
You will configure the Arduino IDE preferences to use that sketchbook location when working on that project. When you want to work on unrelated projects, you would change the sketchbook location to your standard sketchbook.
If you are using Arduino IDE, you can do that through the Preferences dialog. It is also possible to use a script to change the sketchbook location preference if you prefer to make the process less manual. If you are interested in that, we can provide instructions but would need to know which Arduino development software you are using (e.g., Arduino IDE 2.x, Arduino IDE 1.x, Arduino CLI)
I'll provide an example folder structure. Assuming you have two libraries: "Foo" (which is made up of files Foo.h and Foo.cpp) and "Bar" (which is made up of files Bar.h and Bar.cpp), the structure would look like this:
<sketchbook location>/
├── libraries/
│ ├── Bar/
│ │ ├── Bar.cpp
│ │ └── Bar.h
│ ├── Foo/
│ │ ├── Foo.cpp
│ │ └── Foo.h
│ ...
...
(where <sketchbook location> is the path you set in the Arduino IDE "Sketchbook location" preference)
This will only give access to the code in the header file. Unlike with an #include directive for a header file in a normally installed library, this will not result in the compilation of source files in /home/gil/Gil_Lib/.