I have a double variable
double tempTime1; and I want to expose it to read from the API
Spark.variable("tempTime1", &tempTime1, double); and I get the following compiler error
powertarget.cpp: In function 'void setup()':
powertarget.cpp:124:43: error: expected primary-expression before 'double'
Ridiculous. this was purely a matter of case.
Spark.variable("tempTime1", &tempTime1, DOUBLE);
Yes, c/c++ is case sensitive, so
foobar are different symbols.
Just seemed odd to me that the variable declaration
double tempTime1 was lower yet this had to be upper. Inconsistent for me.
Aha! yes, while
DOUBLE both say that you want a variable that is floating point, they are not the same thing - there’s a key difference:
DOUBLE tells the spark cloud what the type of the variable is - the information is accessible to your program.
double tells the compiler to allocate space for a floating point variable. This information is not accessible to your program (your program can’t ask - what’s the type of this variable? - the compiler assumes you know.)
So you see that
double is used to allocate the variable to begin with. while
DOUBLE has to be used to register the variable to the cloud,