particle-iot / ElectronAssetTracker

Library for the Electron Asset Tracker!
Apache License 2.0
53 stars 84 forks source link

Need function declarations in examples #22

Open jenesaisdiq opened 7 years ago

jenesaisdiq commented 7 years ago

Hey @mohitbhoite, I was finally testing the ublox branch and got compile errors on the first example (and I'd expect the others to throw it as well). The errors are that transmitMode, batteryStatus, and gpsPublish are undeclared when Particle.function tries to reference them. Fixed easily by adding these up above setup()

int transmitMode(String command);
int batteryStatus(String command);
int gpsPublish(String command);

This was in Dev. Maybe something's different in Build, or because I was using 061rc2? Worth adding them to all the examples.

MrMarkA commented 7 years ago

I noticed this sometime ago as well. When using the desktop tools (i.e. Atom) C style forward declarations are required. When using the browser based tools(build.particle.io) forward declarations are not required. I have not messed around with the CLI build tools so that remains up in the air.

An alternate solution would be to move the functions (transmitMode, batteryStatus, and gpsPublish) above setup and loop. I am sure some would find that solution stylistically problematic.

@jenesaisdiq, you will probably also discover that any functions you add to the code will either need to have the forward declarations or be be fully defined before the function is first called in the code.

monkbroc commented 7 years ago

I'm sure if you try again it will be fixed. I pushed a fix to the preprocessor today for this very behavior.