Closed rainerschoe closed 3 years ago
Thank you very much, that looks a sane solution, I will test it and report back.
All looks fine @rainerschoe , this is effectively much better, as you correctly stated. Feel free to open a pull-request for the higher level class you wish to contribute. Thank you very much.
This prevents linking errors if PJON is included in multiple compilation units. Also using the static singleton pattern is safer than global vars, especially with multiple compilation units.
Currently projects cannot be linked if PJON.h is included in more than one cpp file, as global vars and function definitions will be there multiple times and cause conflicts.
One solution would be to separate function declarations and definitions into .h[pp] and .cpp files, however in your project you do not seem to use cpp files at all and also do not have a build system set up. So to fix this I just used inlining and the static singleton pattern (for global vars). This will effectively prevent linking errors (might cause some codesize increase).