invalid conversion from 'const unsigned int*' to 'int*' [-fpermissive]

Hello
This is my first post - please bear with me.

I’m trying to compile a code for an ESP32 DEVKIT V1 and it keeps giving me the error “invalid conversion from ‘const unsigned int*’ to ‘int*’ [-fpermissive]”. The code compiles and runs fine on arduino uno and nano (although a version with software serial instead of hardware serial), but when I try to compile it for an ESP32 or ESP8266 board the error is returned. Can anybody explain to me what the problem is and maybe point me toward a solution?
I would be grateful - thx.

The code is supposed to capture IR signals, compares it and sends serial commands to a media player device if there is a match.

This is the code:

#define DEBUG
#include <IRremote.h>


const unsigned int signal1[23] PROGMEM = {850,1700,850,850,850,850,850,850,850,850,850,850,850,850,850,850,850,1700,1700,850,850,1700,850};
const unsigned int signal2[23] PROGMEM = {850,850,850,850,1700,850,850,850,850,850,850,850,850,850,850,850,850,1700,1700,850,850,850,850}; 
const unsigned int signal3[23] PROGMEM = {850,1700,1700,850,850,850,850,850,850,850,850,850,850,850,850,850,850,1700,1700,850,850,1700,850};
const unsigned int signal4[23] PROGMEM = {850,850,1700,1700,850,850,850,850,850,850,850,850,850,850,850,850,850,1700,1700,850,850,1700,850};

const int* signalArray[] = {signal1, signal2, signal3, signal4};
// Calculate the number of elements in the array (there's an assumption here that all patterns are of the same length
const int numSignals = sizeof(signalArray) / sizeof(signalArray[0]);
// Define the correct sequence of buttons that player need to enter
const int correctSequence1 = 0;
const int correctSequence2 = 1;
const int correctSequence3 = 2;
const int correctSequence4 = 3;
const int sequenceLength = 1;
char message;

unsigned long startMillis;  //some global variables available anywhere in the program
unsigned long currentMillis;
const unsigned long period = 12000;  //the value is a number of milliseconds

//Serial to media player
#define RXD2 16
#define TXD2 17

IRrecv irrecv(5);
// Define object to store IR signal received
decode_results results;
// Keep track of how far through the sequence we are
int sequenceProgress = 0;

void setup() {

  Serial2.begin(9600);
  Serial.begin(115200);

  // Start the IR receiver
  Serial.print(F("Initialising IR receiver..."));
  irrecv.enableIRIn();
  Serial.println(F("done"));
  
  // Print the pattern we're listening for
  #ifdef DEBUG
  Serial.print(F("Listening for pattern "));
  for(int i=0; i<sequenceLength; i++){
    Serial.print(correctSequence1);
     Serial.print(correctSequence2);
     Serial.print(correctSequence3);
     Serial.print(correctSequence4);
    Serial.print(" ");
  }
  Serial.println("");
  #endif

}

void sendPatternToSerialMonitor (decode_results *results) {
  // Variable declaration
  Serial.print(F("unsigned int receivedData["));
  // Array size
  Serial.print(results->rawlen - 1, DEC);
  // Begin array
  Serial.print("] = {");
  // Dump data
  for(int i=1; i<results->rawlen; i++) {
    long val = results->rawbuf[i] * USECPERTICK;
    Serial.print(val, DEC);
    if(i<results->rawlen-1) { Serial.print(","); }
  }
  // End printout
  Serial.println("};");
}

// Compare the pattern decoded from the IR sensor to a supplied pattern
bool compareCode(decode_results *results, int code[], int tolerance){
  // Compare each time interval in the results (ignoring the first) to the supplied code
  for(int i=1; i<results->rawlen; i++) {
    long val = results->rawbuf[i] * USECPERTICK;
    int expected = pgm_read_word(&code[i-1]);
    if(abs(val - expected) > tolerance) {
      return false;
    }
  }
  return true;
}


void loop() {
 
  currentMillis = millis();
  if (currentMillis - startMillis >= period)
  { 
    
    // If a valid IR pattern can be decoded
  if(irrecv.decode(&results)) {

    #ifdef DEBUG
      // Dump the pattern received to the serial monitor
      sendPatternToSerialMonitor(&results);
    #endif

    // Loop over each known button and compare to input pattern
    for(int i=0;i<numSignals;i++){
      if(compareCode(&results, signalArray[i], 200)) {
        Serial.print("Pattern matched: ");
        Serial.println(i);

        // Was this the correct next input in the pattern?
       if(i==correctSequence1) {
          #ifdef DEBUG
          #endif
          sequenceProgress++;
          if(sequenceProgress==sequenceLength) {
              Serial2.write(0x01);
              Serial.println(F("---------------"));
              Serial.println("MEDIE1");
              Serial.println(F("---------------"));
              sequenceProgress=0;
              startMillis = millis();
          }
          }

       if(i==correctSequence2) {
          #ifdef DEBUG
          #endif
          sequenceProgress++;
          if(sequenceProgress==sequenceLength) {
              Serial2.write(0x02);
              Serial.println(F("---------------"));
              Serial.println("MEDIE2");
              Serial.println(F("---------------"));
              sequenceProgress=0;
              startMillis = millis();
          }
          }  

        if(i==correctSequence3) {
          #ifdef DEBUG
          #endif
          sequenceProgress++;
          if(sequenceProgress==sequenceLength) {
              Serial2.write(0x03);
              Serial.println(F("---------------"));
              Serial.println("MEDIE3");
              Serial.println(F("---------------"));
              sequenceProgress=0;
              startMillis = millis();
          }
          }

        if(i==correctSequence4) {
          #ifdef DEBUG
          #endif
          sequenceProgress++;
          if(sequenceProgress==sequenceLength) {
              Serial2.write(0x04);
              Serial.println(F("---------------"));
              Serial.println("MEDIE4");
              Serial.println(F("---------------"));
              sequenceProgress=0;
              startMillis = millis();
          }
          }
          
        else {
          #ifdef DEBUG
            Serial.println("Incorrect input! Back to the beginning..");
          #endif
          sequenceProgress=0;
        }
        // Match was found, so no need to check other patterns
        break;
      }
    }
  

    //To prevent repeat button presses, pause before interpreting next signal
    delay(500);
   
    // Receive the next value
    irrecv.resume();
  }
 }
}

And this is the compilation error message:

In file included from C:\Users\jakob\Documents\Arduino\Kladder\SpriteSLET\SpriteSLET.ino:2:0:
C:\Users\jakob\Documents\Arduino\libraries\IRremote/IRremote.h:365:23: error: ‘SEND_PIN’ was not declared in this scope
const int sendPin = SEND_PIN;
^
SpriteSLET:10:63: error: invalid conversion from ‘const unsigned int*’ to ‘const int*’ [-fpermissive]
const int* signalArray = {signal1, signal2, signal3, signal4};
^
SpriteSLET:10:63: error: invalid conversion from ‘const unsigned int*’ to ‘const int*’ [-fpermissive]
SpriteSLET:10:63: error: invalid conversion from ‘const unsigned int*’ to ‘const int*’ [-fpermissive]
SpriteSLET:10:63: error: invalid conversion from ‘const unsigned int*’ to ‘const int*’ [-fpermissive]
C:\Users\jakob\Documents\Arduino\Kladder\SpriteSLET\SpriteSLET.ino: In function ‘void loop()’:
SpriteSLET:107:45: error: invalid conversion from ‘const int*’ to ‘int*’ [-fpermissive]
if(compareCode(&results, signalArray*, 200)) {*

  • ^*
    C:\Users\jakob\Documents\Arduino\Kladder\SpriteSLET\SpriteSLET.ino:78:6: note: initializing argument 2 of ‘bool compareCode(decode_results*, int*, int)’
    bool compareCode(decode_results *results, int code, int tolerance){
  • ^*
    exit status 1
    invalid conversion from ‘const unsigned int*’ to ‘const int*’ [-fpermissive]

Just declare those arrays as int's - the ESP32 is in a totally different world w/regards to memory compared to arduino, you dont need to worry about a few hundred bytes of RAM there. - I don't know how progmem works in ESP32, but I know they have more than enough ram that that piddling amount of data wouldn't be a problem to store in ram, whereas it would be worth the effort to put in progmem on an arduino where it took up a substantial amount of flash., but it has enough memory that you don't care if those sit in ram anyway, and it will make dealnig with the rest of the issue easier.

That particular error comes from implicit conversions (assigning a variable of one type to a variable of a different type in potentially unsafe ways.
Official core, and some third party cores use -fpermissive compiler flag, which tells the compiler to let you get away with reckless implicit type conversions. many purists are horrified by this (and rightly so, as you can easily sleepwalk into bugs that way, not realizing that you're making inappropriate type conversions or what the implications of that are).

But the fact that the official core lets you do it, and some third party cores don't presents a problem when folks like yourself try to run code which they couldn't write themselves at their level of experience, where the orgiinal author didntthat works on official core, only to be stopped because the sloppy person who wrote the code didn't include the necessary explicit casts. The fact that the Arduino IDE defaults to disabling warnings is certainly part of the problem. Who would know that they'd been sloppy with types when they're using an IDE with -fpermissive and warnings off or nearly off?

summary of DrAzzy's post, declare signalArray to be const unsigned int* to match the type of the arrays you're putting into it.