The program below will only compile if the variable is declared 'char'. None of the other variants shown in the code will compile without error. Both .print and .write behave the same.
What is special about 'char', especially as both 'unsigned char' and 'signed char' produce the error?
Also how do I put code in the nice scrolling box?
void setup() {
//uint8_t C[] = "AT"; // Won't compile
//int8_t C[] = "AT"; // Won't compile
//unsigned char C[] = "AT"; // Won't compile
//signed char C[] = "AT"; // Won't compile
char C[] = "AT"; // This is the only version which will compile
Serial.begin(9600);
Serial.write(C,2); // Both .write and .print behave the same
Serial.print(C);
}
void loop() {
}
[EDIT] Because I know someone will ask, the error is:
"call of overloaded 'print(unsigned char [3])' is ambiguous"
AlbertHall:
[Restart:]
The program below will only compile if the variable is declared 'char'. None of the other variants shown in the code will compile without error. Both .print and .write behave the same.
I imagine it's because the prototype for the overloaded function in question (from Print class in Print.h) is:
size_t print(const char[]);
There is no corresponding overload prototype for uint8_t[], unsigned char[], etc.