I'm trying to use this code...
byte buffer [30] = "happy holidays";
byte *ptr = 0;
void setup()
{
Serial.begin(9600);
ptr = strstr(buffer, "day");
if (ptr)
Serial.println("found");
else
Serial.println("not found");
}
void loop()
{
}
It works as expected on an Uno, but when I tried to upload to an ESP32 board I get the following compilation error.
/var/folders/4z/3g9th3gs4cng3b803dg5bhw40000gn/T/arduino_modified_sketch_211243/Blink.ino: In function 'void setup()':
Blink:9:29: error: invalid conversion from 'byte* {aka unsigned char*}' to 'const char*' [-fpermissive]
ptr = strstr(buffer, "day");
^
In file included from /Users/paulibbotson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/include/newlib/stdio.h:29:0,
from /Users/paulibbotson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/cores/esp32/Arduino.h:27,
from sketch/Blink.ino.cpp:1:
/Users/paulibbotson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/include/newlib/string.h:40:15: note: initializing argument 1 of 'char* strstr(const char*, const char*)'
char *_EXFUN(strstr,(const char *, const char *));
^
/Users/paulibbotson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.6/tools/sdk/include/newlib/_ansi.h:65:30: note: in definition of macro '_EXFUN'
#define _EXFUN(name, proto) name proto
^
Blink:9:15: error: invalid conversion from 'char*' to 'byte* {aka unsigned char*}' [-fpermissive]
ptr = strstr(buffer, "day");
^
exit status 1
invalid conversion from 'byte* {aka unsigned char*}' to 'const char*' [-fpermissive]
Looks like it doesn't like the byte format, but just wondering why it works on the Uno.