String stringOne = String(45, HEX); doesn't work? [SOLVED]

The documentation shows this example :

String stringOne = String(45, HEX);

however, I get this error (using cloud compiler) ?

/blink_an_led.cpp: In function ‘void loop()’:
/blink_an_led.cpp:17:39: error: call of overloaded ‘String(int, int)’ is ambiguous
/blink_an_led.cpp:17:39: note: candidates are:
In file included from …/inc/spark_utilities.h:31:0,
from …/inc/spark_wiring.h:34,
from …/inc/application.h:31,
from /blink_an_led.cpp:2:
…/inc/spark_wiring_string.h:78:14: note: String::String(double, int)
…/inc/spark_wiring_string.h:77:14: note: String::String(float, int)
…/inc/spark_wiring_string.h:76:11: note: String::String(long unsigned int, unsigned char)
…/inc/spark_wiring_string.h:75:11: note: String::String(long int, unsigned char)
…/inc/spark_wiring_string.h:74:11: note: String::String(unsigned int, unsigned char)
…/inc/spark_wiring_string.h:73:11: note: String::String(int, unsigned char)
…/inc/spark_wiring_string.h:72:11: note: String::String(unsigned char, unsigned char)
/blink_an_led.cpp:17:12: warning: unused variable ‘stringOne’ [-Wunused-variable]

Hi @mhwlng

This certainly seems like a bug and it would help if you could file an issue with your test case at:

I think the problem is a type issue, could you try this instead:

String stringOne = String(45, (unsigned char)16);

That works for me.

Thanks, that fixed the compiler problem !

1 Like

Filed and fixed in 0.3.3 - https://github.com/spark/firmware/issues/210