Arduino build error

error: invalid operands of types 'const char [6]' and 'const char [6]' to binary 'operator+'

An operator such as + or % was used on types it does not support. Two quoted texts cannot be added. A decimal number has no remainder.

  • Build error
  • 2 common causes
  • Seen 487 times in failed builds on Mokxi in the 30 days to November 16, 2026.
The message

What the Arduino IDE prints

Output window
sketch.ino: In function 'void setup()':
sketch.ino:3:30: error: invalid operands of types 'const char [6]' and 'const char [6]' to binary 'operator+'
    3 |   Serial.println("Hello" + "World");
exit status 1

Convert one side to a type the operator accepts, such as a String.

Mokxi's compiler, clang, words it as invalid operands to binary expression.

Causes

The 2 usual causes with the fix

1Two quoted texts are added with +

Quoted text is not a String, so + does not join it. Make one side a String.

Broken
void setup() {
  Serial.begin(9600);
  Serial.println("Hello " + "World");
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  Serial.println(String("Hello ") + "World");
}

void loop() {
}

Mokxi’s build tab says: Text in quotes cannot be joined with +

Try this fix in Mokxi

2% is used on a float

The remainder operator needs whole numbers. Use fmod() for a float, or convert to int.

Broken
void setup() {
  Serial.begin(9600);
  float angle = 370.5;
  Serial.println(angle % 360);
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  float angle = 370.5;
  Serial.println(fmod(angle, 360));
}

void loop() {
}

Mokxi’s build tab says: float and int cannot be combined with this operator.

Try this fix in Mokxi

FAQ

Questions and answers

How do I join text in Arduino?

Use a String, such as String("a") + "b", or print the parts one after the other with Serial.print.

Why does "Temp: " + 25 compile but print nonsense?

It adds 25 to the address of the text, so it prints the text from the 26th character on. Use String("Temp: ") + 25.

What does fmod do?

It returns the remainder of a division for float values, as % does for whole numbers.