Page 1 of 1

ESP32 memmem?

Posted: Mon May 21, 2018 9:24 pm
by caseymdk
Hi there,

I am trying to use the memmem function from newlib, but I'm getting "error: implicit declaration of function 'memmem'", despite including "string.h".

I can see code for memmem in the newlib code for the esp32...is it for some reason not included in the IDF?

I imagine there is some silly reason I'm missing...would appreciate guidance.

Running IDF V3.0 release (2018-05-16)

Thank you!

Re: ESP32 memmem?

Posted: Sat Jun 15, 2019 11:01 am
by talss89
Hi caseymdk, I know this is an old thread, but in case any one else has the same issue:

memmem is a GNU extension. You need to define a feature test macro: _GNU_SOURCE.

It must be defined before any standard headers have been included.

For example:
  1. #define _GNU_SOURCE
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. char* p = memmmem(foo, foo_sz, bar, bar_sz); // You can now use memmem

Re: ESP32 memmem?

Posted: Mon Jun 17, 2019 8:47 am
by jcsbanks
I appended this to component.mk to use memmem:

Code: Select all

#used for memmem
CFLAGS += -D__GNU_VISIBLE