String.format() (added in 0.4.6) does not compile [SOLVED]


#1

Continuing the discussion from Particle Firmware Update Thread:

I cannot use this new feature, even the Web IDE fails on the provided example code here with error: expected primary-expression before '.' token


#2

I’m poking around in the GitHub repo, and if I’m not totally crazy, it looks like format is not defined anywhere in spark_wiring_string.{h,cpp} for the 0.4.6 release branch. Did you guys miss something?


#3

This seems to work for me?


Photon,Relay Shield and Nextion Touchscreen Based Aquaponics/Indoor Greenhouse
#4

Thanks for the heads up @legoguy - this was an omission, which I’ve rectified just now.


#5

@Moors7, You’re using Time.format() in your example, not String.format() which was just added in 0.4.6. :slight_smile:

@mdma, awesome, thanks for the reply.


#6

My bad, but that is the example you’re referring to as ‘not working’ :wink:


Seems that there’s some issue with duplicated links for different things in the docs. Guess you were indeed referencing the String functions.


#7

Oh weird, looks like the HTML anchors for both String::format() (under the String section of the firmware reference) and Time.format() (under the Libraries section) are exactly the same, so clicking that link brings you to the first one - the Time.format() anchor.

Is this, in itself, a separate issue with the docs?


#8

I’ve raised an issue with the docs here https://github.com/spark/docs/issues/192

Although I think the long term fix should be to prefix each function name with the library it’s contained in. e.g. rather than begin() write Serial.begin() because you never write just begin() in actual firmware.