Particle F() Macro Does not Work with Overloaded String Operator+

Hi Particle Community,

The F() Macro suddenly stopped passing compiling. My code looks like:

  String body = F("{\"particle_id\":\"")+System.deviceID()+

It has always bee all right but all of sudden I got:

 error: conversion from 'const __FlashStringHelper*' to 'const StringSumHelper' is ambiguous
 String body = F("{\"particle_id\":\"")+System.deviceID()+

I switch to Strings but it is commonly known that it is better to save RAM in embedded systems. Is the particle team updating something in the your server? Any idea how to solve the problem?

Thank you very much.

Are you using that same code on Arduinos too?
If not, just dump that macro in Particle code - it does absolutely nothing there.

But the cause is not actually the F() macro but the order of execution of your instruction.
And ambiguity error just indicates that there are several overloads for on method/operator and by looking at your instruction the compiler can’t decide which one to use.

And as you said, to conserve RAM and cobsequently not prepare for delayed crashes of your code I’d suggest to stick with char[].
But if you “need” to use String for some obscure reason at least pre-reserve a big enough buffer to prevent relocation due to outgrowing default buffers multiple times.

To get rid of the error try this instead

String body;
body += .....;
body += ....;

But again, I’d rather use snprintf() for complex string building.

1 Like