Particle Build is throwing several errors like this:
error: ‘uint8_t’ does not name a type
I’m sorry to say that this is not a new topic, I’ve read through the other posts on the same problem. But I have #include “application.h” in the .ino and .cpp files. This is what is prescribed in most of the replies. Still getting this error.
These type are listed in the Reference > Data Type section.
This is a port of an Arduino project to Particle Electron. Any further suggests would be appreciated.
“Background” information:
The problem here seems to be the fact that only.ino files undergo the Wiring preprocessing which implicitly adds the #include <Particle.h> (= more recent version of application.h) statement which in turn includes the required headers, including types.h
While the #pragma switches off the preprocessor for .ino files and hence the explicit #include is required, for .h & .cpp files this explicit `#include’ is always required (direct or indirect).
BTW, from 0.6.2 on, porting Arduino libraries should be a fair bit simpler - as long there is no hardware specific code but standard Wiring code.
By not including Particle.h but Arduino.h a different set of #includes will be pulled in to enable a direct build with no alterations at all (in many cases).
Knowing which library you’re trying to port, might help to tell whether this needs “proper” porting or might just require some minor tweaks.
The goal is to integrate this SeeedStudio multichannel gas sensor with an Electron. They communciate via I2C. The Arduino code for reading the sensor runs out-of-the-box on an Arduino Uno R3.
I have attempted to compile on both Particle Dev and Particle Build. Currently I'm compiling with Build, and flashing with CLI.
There are several Arduino programs included with the sensor. For example, GetVersion.ino compiles and runs. This short program obviously uses the same .cpp and .h files. Yet all of the compile errors are thrown from the .h file.
@cermak, this might work (or not depending on module build order which is non-deterministic in the online build farm), but it is bad practice to rely on the order of include statements.
It would be better to have each individual file and module to be selfcontained by having the required include statements directly inside their own body.