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

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

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?

This seems to work for me?

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

@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.

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.

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?

1 Like

I’ve raised an issue with the docs here

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.