Building code that compiles in both IDE and CLI

I have found that when I compile locally I don’t need a path in my includes as they are all in the same directory, however when I use it as a library in the IDE I need to include the path to the header file in the examples. I would like to not have to change the include paths in the example files when I build locally and in the IDE. I was wondering if there was a flag what was defined when building in the different environments.

For example in the PietteTech_DHT library I have to include the library .h file in the example using the following path when compiling in the IDE

#include "PietteTech_DHT/PietteTech_DHT.h"  // Uncomment if building in IDE
//#include "PietteTech_DHT.h"                 // Uncomment if building using CLI

If would be nice if I could just test #if defined(PARTICLE_IDE) such that I would rewrite this as

#if defined(PARTICLE_IDE)
#include "PietteTech_DHT/PietteTech_DHT.h"  // Building in IDE
#include "PietteTech_DHT.h"                 // Building using CLI

Is there anyway to detect if the code it being built in the IDE?

1 Like

Hi @mtnscott

The Particle team recognized this problem some time ago and is working on it. I think the eventual solution will just require the non-hierarchical #include "library_name.h" in all cases but it is still being worked on.

I am not sure of the schedule for this but work is underway.

@bko Thanks!