Compilation FAILS #define ARDUINO?


#1

Here is a strange error!
I have lots of codes that had been compiled successfully in the cloud till now using SD_FAT_PARTICLE_MASTER library .
But suddenly all of them compile with the error caused because it is trying to include libraries inside #Ifdef ARDUNO when compilation.
I have not #defined ARDUINO anywhere …i am working with an electron 3g.
It seems that the IDE don’t tell the compiler the ID of my electron (in this case) that i am using and decides itself that i am using an Arduino.
In fact that happened to me 6 days ago and everything worked good the next day. and now again the same problem.
Someone else has sealed with this?


#2

I guess this is due to the recent “improvements” towards Arduino compatibility
See here


You could try adding

#pragma PARTICLE_NO_ARDUINO_COMPATIBILITY

or you target 0.6.0 till the issue gets addressed.

But I’m not sure. We can ping @BDub and @jvanier about this.

BTW, this SDFat library should be better to use now as it has some major improvements built in.


#3

Pragma instruction doesn’t seem to work.
The firmware version i use is 0.6.0 already.
So it seems we all just have to wait till they stabilize their changes?


#4

Can you post a link to the library?


#5

As @ScruffR mentions keep using 0.6.0 until this is addressed in a future version.


#6

@loscos, can you double check that you are actually building for 0.6.0 - having 0.6.0 installed on the target device is only half the equation.


#7

To provide maximum compatibility for Arduino libraries, and still support hundreds of libraries that we ported from Arduino to Particle, we include Arduino defines by default now.

In the past, users would get Arduino defines without the need to add #include "Arduino.h" to their code.

Now Arduino.h just includes Particle.h (which in turn includes the legacy application.h). If application.h is included, PARTICLE_ARDUINO_COMPATIBILITY will be defined. And by default it will be included and set to 1. If that is the case, all of the defines in spark_wiring_arduino.h will be included in your code. So ARDUINO will be defined.

Code in Arduino libraries like this should compile fine

#if (ARDUINO >= 100)
 #include <Arduino.h>
#else
 #include <WProgram.h>
 #include <pins_arduino.h>
#endif

If you’ve added your own tests on ARDUINO though, you have to understand now that it will be included by default and you may have to change something.

Can you show me the code for the library you are compiling so I can take a look?


#8

If you absolutely need to undefine something, you can add statements like this

#ifdef ARDUINO
  #undef ARDUINO
#endif

#9

You can also do this:

#pragma PARTICLE_NO_PREPROCESSOR
#define PARTICLE_NO_ARDUINO_COMPATIBILITY 1
#include “Particle.h”

but you would need to ensure there are no other includes anywhere in other files for Particle.h, Arduino.h or application.h, which would default PARTICLE_NO_ARDUINO_COMPATIBILITY to 0 (thereby including those Arduino defines).


#10

At this moments things are like this.
-1)The library i was using was the one that @ScruffR has linked me but in its old version (I can’t find the link) that …YES! has different includes (ifdefs ARDUINOS,…).So changing the library at least the project could have been compiled.
-2)The firmware in my electron was the 0.6.0 so nothing worked because by default desktop IDE compiles for the las version 0.6.1.
-3)So updating the electron and changing the libraries it seems its going to work but i can’t be sure till i’ll do some prubes on monday when my office opens its doors.
Thanks for the information and for your help!


#11

You can build a Dev project version targetted with CLI via

particle compile electron <projectFolder> --target 0.6.0