Compiler differences for nano and nano 33 IoT

I Have a simple project that reads a 3Cx4R keypad which uses a single character lookup using Keypad.h to determine the location of the key presses. There multiple keypads used and depending on product model Key functionality in any position (rxc) may have different functions. I then have a function getKey that look for a test string that was assigned to the specific key location. I then search for the string function name and perform specific control.

The code compiles and runs fine on Arduino Nano. However simply changing the board to Arduino Nano 33 IoT the compiler fails on any use of my getKey function.

// uses the keypad row and col as index to string description of key functions.

char* getKey(char *k)
{ for(int i=0; i<16; i++) {
if(specialKeysID[i] == k) return specialKeys[i]; }
}

error: "C++ forbids comparison between pointer and integer [-fpermissive]
if(specialKeysID[i] == k) return specialKeys[i]; } "*
This error occurs on every occurrence of getKey() function call.

eg: getKey(keyPressed)

No Error message on nano and other non wifi and BT boards

Can anyone explain what is preventing this from compiling on the nano33Iot or why is is able to compile on Nano given the error message.

Complete simplified code:

// Correct software for Smart with top cable keypad s-w connection should work on PCB v2

//#define conditional compilation

// Keypad defines
//define KEYPAD_BLUE_SMALL
//#define KEYPAD_GREEN
//#define KEYPAD_PLUS
//#define KEYPAD_PHONE
//#define KEYPAD_STOP3
//#define KEYPAD_CYD
#define KEYPAD_PLUS_INVERTED


int PRESSURE      = 4;        // Arduino D4 - How2 PRESSURE INPUT to detect PRESSURE SW state
int count         = 0;        // 
int FLOW          = 8;        // Arduino D8 - How2 HI/LO Pwr/Water connector Pin3 {Original LEDgrey}
int WATER         = 9;        // Arduino D9 - How2 WATER Turns Water off/on bypasses Pin8 HI/LO control affects WATER_OUT {Original LEDwhite}
int Solution_1    = 6;   // Arduino D6 - HOW2 Solution_1 control for Solution_1_OUT [original LEDred]
int Solution_2    = 5;   // Arduino D5 - HOW2 Solution_2 control for Solution_2_OUT {original LEDyellow}
int Solution_3    = 3;   // Arduino D3 - HOW2 Solution_3 control for Solution_3_OUT [original LEDblue]
int LED           = 13;
int LED_ON        = HIGH;
int LED_OFF       = LOW;
char* keyFunction = "";

// Time related variable declarations
int KEY_PRESS_TIME_OUT;
int tt=0;
//int D10 = 10;
int i;  // itterationloop index
//void(* resetFunc) (void) = 0;
// these are the "formulas"
//    175-255         100-255

int flowRate_MAX  = 255;   //Originally multiple <color>LED = <value>
int flowRate_OFF  = 0; 
int flowRate_100  = 100; 
int flowRate_125  = 125;
int flowRate_150  = 150 ;

// TIMER VARIABLES
unsigned int long time;
unsigned int long KEYPRESS_TIMER_START; //start of program
unsigned int long KEYPRESS_TIMER_NOW; //start of program
unsigned int long KEYPRESS_TIMER; //start of program
int               KEYPRESSED_TIME_MAX = 10;
bool              KEYPRESS_TIMEOUT    = false;     

/* @file CustomKeypad.pde
  || @version 1.0
  || @author Alexander Brevig
  || @contact alexanderbrevig@gmail.com
  || @description
  || | Demonstrates changing the keypad size and key values.
  || #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
//define the symbols on the buttons of the keypads

#if defined KEYPAD_BLUE_SMALL
char* specialKeys[] = { 
        "200ppm Sanitizer",     "400ppm Sanitizer", "Glass Cleaner",
        "Restroom Cleaner",     "Sink Cleaner",     "Toilet Bowel Cleaner",
        "All Purpose Cleaner",  "Mild Cleaner",     "Heavy Duty Cleaner",
        "STOP",                 "Rinse",            "ERROR"
};
#endif

#ifdef KEYPAD_GREEN
char* specialKeys[] = { 
        "Glass",                "Floors",           "Degreaser",
        "Restroom LD",          "Restroom MD",      "Restroom HD",
        "Restroom Sink",        "Stop",             "Toilet",
        "Clean",                "Rinse",            "Sanitize"
};
#endif

#ifdef KEYPAD_PLUS
char* specialKeys[] = { 
        "Hand Soap LD",           "Hand Soap MD",       "Hand Soap HD",
        "Glass",                  "Floors",             "Degreaser",
        "Restroom",               "STOP",               "Toilet",
        "Clean",                  "Rinse",              "Sanitize"
};
#endif

#ifdef KEYPAD_PLUS_INVERTED
char* specialKeys[] = { 
        "ERROR",                  "Rinse",              "STOP",
        "Hand Soap HD",           "Hand Soap MD",       "Hand Soap LD",
        "Toilet",                 "Cleaner MD",         "Cleaner LD",
        "Glass",                  "400ppm Sanitizer",    "200ppm Sanitizer"
};
#endif



#ifndef KEYPAD_PLUS_INVERTED
char specialKeysID[] = {
  '1', '2', '3',
  '4', '5', '6',
  '7', '8', '9',
  '*', '0', '#',
};

#else // inverted plus keyboard mapping
char specialKeysID[] = {
  '#', '0', '*',
  '9', '8', '7',
  '6', '5', '4',
  '3', '2', '1',
};
#endif


char keys[ROWS][COLS] = {
{specialKeysID[0],  specialKeysID[1],   specialKeysID[2]},
{specialKeysID[3],  specialKeysID[4],   specialKeysID[5]},
{specialKeysID[6],  specialKeysID[7],   specialKeysID[8]},
{specialKeysID[9],  specialKeysID[10],  specialKeysID[11]}
};

byte rowPins[ROWS] = { A3, A2, A1, A0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = { 10, A5, A4}; //connect to the column pinouts of the keypad


Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


int timeOut;
int totalTime = 2; //total time
int timeElapsed; //Time elasped
int ifDelay = 500;



// ************** SETUP CODE **************
//
void setup() {
  Serial.begin(9600);

  pinMode(10,OUTPUT);
  digitalWrite(PRESSURE, HIGH);
  delay(20);
  pinMode(PRESSURE, OUTPUT);

  pinMode(WATER, OUTPUT);
  pinMode(FLOW, OUTPUT);
  pinMode(Solution_2, OUTPUT);
  pinMode(Solution_3, OUTPUT);
  pinMode(Solution_1, OUTPUT);
  pinMode(LED,OUTPUT);
  digitalWrite(WATER, LOW);
  digitalWrite(FLOW, LOW);
  digitalWrite(Solution_2, LOW);
  digitalWrite(Solution_3, LOW);
  digitalWrite(Solution_1, LOW);
  Serial.println("");
  Serial.println(".....");
  Serial.println("Start Scanning Keypad:\r \b\b\b\b asds");
  Serial.print("");
} // end seetup

// ****************** MAIN CODE LOOP *******************
//
void loop() {
// digitalWrite(LED, LED_ON);
// delay(100);
// digitalWrite(LED,LED_OFF);
// delay(1000);
KEYPRESS_TIMEOUT = false;
KEYPRESS_TIMER_NOW = millis();
    char keyPressed = customKeypad.getKey();
    if (keyPressed){
        KEYPRESS_TIMER_START = KEYPRESS_TIMER_NOW; 
        Serial.print("Key Pressed was: ");
        Serial.println(keyPressed);
        Serial.println(getKey(keyPressed));
        Serial.println("");
        } 
    else {
        KEYPRESS_TIMEOUT = checkforKeyPresstimeOut(); 
        }

   
      KEYPRESS_TIMEOUT = checkforKeyPresstimeOut();
      if (getKey(keyPressed) == "STOP" || KEYPRESS_TIMEOUT == true) 
      {
        Serial.print("Dispensing stopped, waiting on keypress: "); Serial.println(KEYPRESS_TIMEOUT);
        digitalWrite(FLOW, LOW);
        digitalWrite(WATER,     flowRate_OFF);
        analogWrite(Solution_2, flowRate_OFF);
        analogWrite(Solution_3, flowRate_MAX);
        analogWrite(Solution_1, flowRate_OFF);
        KEYPRESS_TIMER_START = KEYPRESS_TIMER_NOW;
        KEYPRESS_TIMEOUT = false;
        Serial.println(KEYPRESS_TIMEOUT);
      }

      // 1
      if (getKey(keyPressed) == "200ppm Sanitizer") {
       analogWrite(Solution_1, flowRate_OFF);
      }


      // 2
   
      if (getKey(keyPressed) == "400ppm Sanitizer") {
        //Serial.print("400ppm key presseed");
        analogWrite(Solution_1, flowRate_MAX);
      }


       // 3

      if (getKey(keyPressed) == "Glass Cleaner") {
        analogWrite(Solution_3, flowRate_150);
      }

       // 4

  if (getKey(keyPressed) == "Restroom Cleaner") {
        analogWrite(Solution_3, flowRate_100);
      }

       // 5
      if (getKey(keyPressed) == "Sink Cleaner") {
        digitalWrite(WATER, HIGH);
      }


       // 6
     
      if (getKey(keyPressed) == "Toilet Bowel Cleaner") {
        digitalWrite(FLOW, LOW);
      }

       // 7
     
      if (getKey(keyPressed) == "All Putpose Cleaner") {
        analogWrite(Solution_1, flowRate_OFF);
      }

       // 8
     
      if (getKey(keyPressed) == "Mild Cleaner") {
      }

       // 9
     
      if (getKey(keyPressed) == "Heavey Duty Cleaner") {
          analogWrite(Solution_1, flowRate_OFF);
      }

       // *
     
      if (getKey(keyPressed) == "Rinse") {
        digitalWrite(WATER, HIGH);
        analogWrite(Solution_1, flowRate_MAX);
      }

       // 0
     

       // #
     
      if(getKey(keyPressed) =="ERROR")
      {
        //Serial.print("ERROR: ");
      }
       
      if (getKey(keyPressed) == "Hand Soap LD") {
         analogWrite(Solution_1, flowRate_MAX);
      }

      if (getKey(keyPressed) == "Hand Soap MD") {
        analogWrite(Solution_1, flowRate_MAX);
      }

      if (getKey(keyPressed) == "Hand Soap HD") {
        analogWrite(Solution_1, flowRate_MAX);
      }

      if (getKey(keyPressed) == "Floors") {
        analogWrite(Solution_1, flowRate_MAX);
      }


      if (getKey(keyPressed) == "Degreaser") {
        digitalWrite(WATER, HIGH);
      }


      if (getKey(keyPressed) == "Sanitize") {
        digitalWrite(WATER, HIGH);
        digitalWrite(FLOW, LOW);
        analogWrite(Solution_2, flowRate_OFF);
        analogWrite(Solution_3, flowRate_OFF);
        analogWrite(Solution_1, flowRate_MAX);
      }


}  // end loop


// *******************
// *   myFunctions   *
// *******************

char* getKey(char *k)
{ for(int i=0; i<16; i++) {
     if(specialKeysID[i] == k) return specialKeys[i]; } 
}

unsigned long displayStartTime(){
    KEYPRESS_TIMER_START = millis(); 
    Serial.print( "Initialized keypress time to: "); 
    Serial.println(KEYPRESS_TIMER_START); Serial.println("sec");
    return(KEYPRESS_TIMER_START);
}

int checkforKeyPresstimeOut() {
    KEYPRESS_TIMER_NOW  =   millis();
    KEYPRESS_TIMER       =   KEYPRESS_TIMER_NOW - KEYPRESS_TIMER_START;
    if (KEYPRESS_TIMER   >=  KEYPRESSED_TIME_MAX * 1000){
        KEYPRESS_TIMEOUT = true;
        return(KEYPRESS_TIMEOUT);
    }
}

the code you posted is riddled with errors
i don't see how the same code could have been successfully compiled for another processor with the same compiler.

i do see that it compiles wihout any compiler warnings

Hi GCJr

Thanks for the reply, This is my first post and was surprised to see such a fast response. I'm not surprised there are errors in this. I'm just a H/W designer fumbling my way through some c++ code to control some water and solution pumps.

When you say you saw it 'compile without error" were you able to compile for both the Arduino Nano and Arduino Nano33 IoT. If so I'll double check my board installation of the IoT board.

Do you see any coding errors in the "riddles errors" related to my getKey() function.

Either way Thanks again,

Try this:

char* getKey(char k)
{ for(int i=0; i<16; i++) {
     if(specialKeysID[i] == k) return specialKeys[i]; } 
}

It's that :angry: :rage: :angry: -fpermissive :angry: :rage: :angry: in the AVR core.

The procedure getKey() in the OP's code contains a logical error that will cause the code to execute incorrectly on any controller, regardless of whether there are warnings during compilation or not.

Apart from these

C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:24:21: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:96:1: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino: In function 'void loop()':
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:193:41: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:202:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:202:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:217:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:217:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:224:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:224:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:232:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:232:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:239:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:239:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:245:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:245:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:252:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:252:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:259:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:259:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:266:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:266:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:272:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:272:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:279:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:279:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:289:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:289:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:294:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:294:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:299:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:299:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:304:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:304:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:309:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:309:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:314:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:314:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:319:26: warning: invalid conversion from 'char' to 'char*' [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:334:8: note:   initializing argument 1 of 'char* getKey(char*)'
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:319:31: warning: comparison with string literal results in unspecified behavior [-Waddress]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino: In function 'char* getKey(char*)':
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:338:33: warning: ISO C++ forbids comparison between pointer and integer [-fpermissive]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino: In function 'int checkforKeyPresstimeOut()':
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:355:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino: In function 'char* getKey(char*)':
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:340:1: warning: control reaches end of non-void function [-Wreturn-type]
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino: In function 'int checkforKeyPresstimeOut()':
C:\Users\Bob2\AppData\Local\Temp\.arduinoIDE-unsaved2024811-9488-y7aj47.yzkh\sketch_sep11a\sketch_sep11a.ino:360:1: warning: control reaches end of non-void function [-Wreturn-type]

did you try with compiler warnings turned off ?

No
Why would I ?

to understand why he said it didn't generate and errors when compiled for nano33Iot.

and yes, i'd be surprised that it ran properly without correcting the warnings

First of all thanks to all for the input/feedback:
This is my first post so I'm not sure if replies to every one.. so forgive me if this reply is not handled properly

b707 -
Yes changing the code as you suggested to :

char* getKey(char k)
{ for(int i=0; i<16; i++) {
     if(specialKeysID[i] == k) return specialKeys[i]; } 
}type or paste code here

// rather than 

char* getKey(char *k)
{ for(int i=0; i<16; i++) {
     if(specialKeysID[i] == k) return specialKeys[i]; } 
}

Allowed the code to compile for both boards - thanks
that is not to say the code runs on both board the same -
in-that Nano board gives the output expect on a keypress.
but running the Nano 33 IoT board the code does not run as expected, it does not seem to recognize keypresses.

Output from Nano with #define KEYPAD_PLUS_INVERTED
9:15:47.002 -> Start Scanning Keypad:  asds
19:15:50.862 -> Key Pressed was: 1
19:15:50.862 -> 200ppm Sanitizer
19:15:50.910 ->
19:15:50.910 -> Setting Dispensinng for 200ppm Cleaner ...
19:15:52.956 -> Key Pressed was: 2
19:15:52.956 -> 400ppm Sanitizer

Output from Nano 33 IOT with #define KEYPAD_PLUS_INVERTED runs "STOP" key infinitem:

19:38:48.483 -> Dispensing stopped, waiting on keypress: 1
19:38:48.483 -> 0
19:38:48.483 -> Dispensing stopped, waiting on keypress: 1
19:38:48.483 -> 0

UKHelBob

WRT the warning turning on and off I'm running Arduino Sketch IDE and after installing board libraries and compiling i'm assuming the warnings were turned off by default. I'm very new to all the and I"m not sure even where or what to edit to turn them on.

oqibidipo and gcjr

WRT same code compiling same code for two different processors - I had assumed that changing the board type in the IDE would automatically compile runtime code for any new processor.

gcJr
What is "-permissive" for the aVR core. It sounds like I don't like it either :cowboy_hat_face:

What is "-fpermissive" in the AVR core?

under the IDE File tab is an option for Compiler Warnings which i normally set to "More". this means it not only reports warning but treats them as errors. see post #8.

the reason this isn't the default is because legacy code may not compile even though it is successfully in service out in the field.

Under File/Preferences

b707

I'm going tp mark this as the solution since it definitely fixed addressed the difference on compile for the two boards. Lookin at using just 'char k' for the parameter passed makes sense and leaves me wondering why I had the * which I thought was saying that k was a string character. This is my first c++ program and I guess I need to go back and get a better understanding of type usage/definitions and limitations. WRT not running he same on the two boards; I think is a different issue that I'll try to sort out. Several of you pointed out that the code is 'riddled with errors' so time to get up to speed a bit better. Thanks again

Thanks for the added detail on the warning/error setup. I'm running IDE version 2.3.2 Feb20-2024. there is no "Compiler Warnings" option under files or under "Files/Preferences" as UKHeliBob suggested. I did fine "File/Setting" which opens up a gut titled preferences. however I turned on Verbose compile options but this guy would not close out hitting OK I had to exit out with x which obviously did not save the changes.

I'll work through this and if i can't resolve, I'll open a seperate issue since this is only remotely related to the issue I opened.

thanks to all again for the feedback -

Are you sure ?

1 Like

oh, sure, that one

None directly under The File menu Item, I did get to the image you sent by Menu Arduino IDE /Setting. I then marked the verbose and error all options as suggested.

and got ...

however I was unable to save/close out using the OK button on bottom right of gui.

**Ahh!!! ** but there is order in the universe again... I completely shutdown and restarted every thing. Results:

  • Nano board compiles w/o error or warning just a very verbose output
  • Nano 33 IoT board compile w/o errors but 2 warning related to PinMode
    * "Using pinMode() INPUT_PULLUP AVR emulation"
    * This may be causing keypad not to rue reading keypress correctly and the
    reason the code runs differently.

Thanks again

Which OS and version of the IDE are you using ?

Sorry should have put this in the original post:

Hardware: Macbook pro 2018 15"
MacOS: Sanoma 14.6.1
Arduino IDE: 2.3.2