I have tried to declare an enum with a value DEC but compilation fails bacause of a #define DEC is within Print.h
I have declared this enum in a class in a .h header file of my own. I’ve tried wrapping the whole class into a custom namespace but it still fails.
Any ideas ?
Probably the best solution is to use a different name.
You could also do this:
The definition of DEC in the Arduino core library is brought in by the code the Arduino IDE’s automatic insertion of the following code into the sketch’s .ino file:
The Arduino IDE does not do that for .cpp files so you could move all the code that relies on your enum to .cpp files and not include your .h file in any .ino files. It’s even possible to prevent the inclusion of Arduino.h into the .ino file by adding this code to your sketch:
but then you will not have access to any of the Arduino core library features in your sketch.
Why must the enum have a value called DEC?
Call the value something that isnt already a defined macro.
Thanks guys. I am defining a enum for processor op codes and DEC happens to be one.
I haven’t figured out how ok going to do it yet; but I had an idea that if I read an instruction into memory I’d be able to find a fast way of mapping the op code string into an object defined by an enum or const key.