Is it possible to ignore library files in the WebIDE at compile time?
I have two Xenons running small epaper displays, both are slightly different (one is red, black and white, the other just black and white), so need a different library to drive then. As both are going to perform the same function, I was hoping to decide which library to use with a #define and use the same code for everything else.
I get the same error. If I delete the two files I’m not using for ER-ERM0154-1.h, it compiles fine.
Is there a way I can say ‘completely ignore ER-ERM0154-1.h’? It looks like although I have not included it, it tries to compile it then finds two definitions for Epd and errors.
foo.h does not exist, application.h does. If I #define FOO 1 I get an error, but do not if I run the code exactly as above.
I suspect your multiple definition error is coming from somewhere else. One way to fix this would be to put something like this at the top of your header files:
Thanks for the suggestions. I have played around with this for a bit and I can’t get it to work. Even with the ifdef, else, I seem to either get both libraries or neither, which does not make much sense.
While I have been struggling to get this to compile, I have thought of a few other features & hardware I want to add to one of the two devices, so I think I’m going to fork the project anyway, otherwise it is going to get far too complicated!
Sorry, I have been struggling for time to come back to this. I have put together the following project to just look at the library inclusion. The code should take control of the status LED and show it yellow for 3 seconds, after another 3 seconds it will turn it to blue if we are using the first library and green if we are using the second. https://go.particle.io/shared_apps/5eb84a6861bddd000c5bbc8e
I want to be able to decide which library to use by commenting and uncommenting #define USEONE 1
Just using the #ifdef in the main file, tries to compile both libraries and I get a conflict as there are two definitions of showRunning(). To prevent this,I have put a #ifdef USEONE in libOne and a #ifndef USEONE in libTwo. With #defile USEONE commented out, this works fine and the LED goes green. However if I remove the comments, to make sure USEONE is defined, it still ignores the libOne and it still goes green, not blue. libOne is still ignored.
It looks like the #define USEONE is only local to the main file. Is there any way I can declare this globally, or am I doing the wrong thing to decide which library to include?