Build.io flash logic warns about valid - but moved - includes

(you may want to create a category for build.io web behaviors…)

I get a popup when I flash my device:

You are not including

LiquidTWI.h elapsedMillis.h Arduino.h
even though they are a part of this app.

Are you sure you want to continue?

To include these files, please hit cancel and add include lines to the top of the 
to the top of the main app file.

My sketch starts with a large 70+ line comment (copyright and context…), with my #includes laid out below
All the mentioned includes are actually included there.

This check should either be dropped (i.e., the compile would have failed before the OTA invocation can start, so this check/report is redundant at best) or changed to actually look for the includes in the whole sketch. There is nothing “special” about “at the top of the app”.

1 Like

One thing, you don’t use Arduino.h on Particle devices.

And the other is, when you need to use libraries, it’s not enough to just insert the #include statement but you need to import the libraries into your build repository.
This is either done by adding the respective files as new code tabs and paste the code there or via the library button (bookmark symbol) in Particle Build.

Have a look here
https://docs.particle.io/guide/getting-started/build/photon/#using-libraries

You missed the point - these are libraries I have imported or have as code tabs.

One tab happens to be called Arduino.h - which I created to deal with the undesirable arbitrary incompatibilities between Arduino and particle environs… The libraries are not the problem here - the code compiles and runs OK.

The bug here is easy to reproduce: add a 100 line comment before the first library or code tab #include in your sketch’s .ino file and then try to flash it from the web IDE: you will get a gratuitous pop up telling you that you need to put includes at the top of your sketch…

John

Hi @JohnP

I think you are running into a limitation of the Particle version of the preprocessor for Wiring. This wonderful thing makes it so that you don’t have to write function prototypes or worry about forward references in general, but it does this by re-arranging your code.

You can turn the preprocessor off with a pragma but then you are required to include application.h and handle straight C/C++ authoring rules.

#pragma SPARK_NO_PREPROCESSOR
#include "application.h"

Oh sorry, I might not have missed the point if it had been mentioned :wink:

But in this case, I'd second @bko's suspission.

Hi @JohnP,

Thanks for reporting! I’m guessing you’re getting this warning regardless of the SPARK_NO_PREPROCESSOR flag, is that right? I’ve pinged our Build IDE team about this issue.

Thanks,
David

Hey @JohnP I can’t reproduce your issue. This flashes without warning. Are there any steps you didn’t mentioned to make it happen?

MacOS/Chrome, a mix of shared and private libs. The build succeeds - the problem is only the gratuitous (and incorrect) popup :smile: There is no need for SPARK_NO_PREPROCESSOR, though I fully understand the reasoning behind it. If anything, the only nit is that the Particle preprocessor magic is different from that used by the Arduino community today in some non-obvious way…

To be clear, this is a low priority nit, even if it triggers some head scratching…

As an aside, what’s the best way to securely share my build.io sketch with you? Is it OK to post the 24 character ID in a public forum like this?

(FYI, LiquidTWI is included on line 139…)

You can always send a PM.