Arduino build error

error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

A piece of text, a char array or a string literal, is a pointer. A single character or a number is an integer. They cannot be compared with ==.

  • 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:6:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
    6 |   if (word == 'a') {
exit status 1

Compare one character with one character, or compare text with strcmp() or a String.

Mokxi's compiler, clang, words it as comparison between pointer and integer.

Causes

The 2 usual causes with the fix

1A whole word is compared with one character

'a' is one character. word is a row of them. Compare one item of the row, or compare the whole word with strcmp.

Broken
void setup() {
  Serial.begin(9600);
  char word[] = "abc";
  if (word == 'a') {
    Serial.println("match");
  }
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  char word[] = "abc";
  if (word[0] == 'a') {
    Serial.println("match");
  }
}

void loop() {
}

Mokxi’s build tab says: Text in quotes, or a char array, is a pointer

Try this fix in Mokxi

2A number is compared with text in quotes

The quotes make "5" text. A number needs no quotes.

Broken
void setup() {
  Serial.begin(9600);
  int level = 5;
  if (level == "5") {
    Serial.println("five");
  }
}

void loop() {
}
Fixed
void setup() {
  Serial.begin(9600);
  int level = 5;
  if (level == 5) {
    Serial.println("five");
  }
}

void loop() {
}

Mokxi’s build tab says: Text in quotes, or a char array, is a pointer

Try this fix in Mokxi

FAQ

Questions and answers

How do I compare two pieces of text?

With strcmp(a, b) == 0 for char arrays, or == between two Strings.

What is the difference between 'a' and "a"?

'a' is one character. "a" is text: the letter and a zero that ends it.

Why does == on char arrays not work?

It compares where the arrays are in memory, not what they hold. Use strcmp.