arduino_midi_library icon indicating copy to clipboard operation
arduino_midi_library copied to clipboard

allow different name for namespace

Open modularev opened this issue 3 years ago • 3 comments

modularev avatar Feb 26 '22 15:02 modularev

How would that work in practice?

A #define MIDI_NAMESPACE foo before including MIDI.h would only apply to the current compilation unit, and not to MIDI.cpp for example.

If you're thinking of defining it as a compiler flag (which would apply everywhere), could you add documentation on how to proceed?

franky47 avatar Feb 26 '22 16:02 franky47

I did not think of that.. I am working on a project which depends on another class named midi - I think in my case it seems having done the trick - although I certainly need to read up on the usage of namespace...

adding a compiler flag would certainly be possible. However, would you have another in-code solution in mind?

modularev avatar Feb 26 '22 16:02 modularev

Your suggestion could work in combination with a platform.local.txt, an undocumented override to the Arduino compiler, which could set the value of MIDI_NAMESPACE as a preprocessor flag:

compiler.cpreprocessor.flags=-DMIDI_NAMESPACE=mycustommidinamespace

https://github.com/arduino/Arduino/issues/3371 https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

franky47 avatar Mar 02 '22 11:03 franky47