Photon + SystemThread(Enabled) causing compile issues?

OK, I have a XBee library I’m using and it compiles and runs just fine in Particle DEV as seen in the screenshot below:

Now when I try to add SYSTEM_THREAD(ENABLED); to the top of the sketch the compiler starts throwing the errors for some reason.

Any ideas why adding the System Thread command at the top of the sketch would cause these issues when otherwise without that command everything compiles and runs just fine?

I’ve seen similar issues.
Can you try putting SYSTEM_THREAD(ENABLED) after your #include block?

1 Like

Of course that fixed it :blush:

I always thought that had to be called first so didn’t try it below the includes :slight_smile:

1 Like

I think the issue stems from the #include <Particle.h> statement that’s inside the header file you are including.
Usually the preprocessor adds that include statement at the top of you code, when it’s not found, hence even if you write SYSTEM_THREAD(ENABLED) as top line in your .ino file that #include <Particle.h> will end up before it, but when you have Particle.h already there but after the “call” of the SYSTEM_THREAD() macro the compiler gets confused.

I don’t have #include <Particle.h> At the top of the .ino or any of the .h or .cpp files.

Then something else causes the preprocessor to trip and confuse the compiler :wink:

1 Like

Haven’t tried to compile using the Visual Studio setup yet although I do have it installed.

Wonder if it would have done the same.

Can I flash over Wifi easily with Visual Studio the same as I do with Particle Dev? Or is it more complicated than that?

I think it's pretty much the same (maybe one/two extra clicks, but that will be stream lined).
And you can falsh via USB and most importantly build without internet connection.

But editing, refactoring, maintenance, debugging (to come) is just that much better.
I never was a Dev fan, but with Workbench I don't see any raison d'être for it anymore at all.

1 Like