ESP32 memmem?

caseymdk
Posts: 15
Joined: Wed Feb 07, 2018 2:35 am

ESP32 memmem?

Postby caseymdk » Mon May 21, 2018 9:24 pm

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!

talss89
Posts: 2
Joined: Fri Oct 26, 2018 8:12 pm

Re: ESP32 memmem?

Postby talss89 » Sat Jun 15, 2019 11:01 am

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

jcsbanks
Posts: 305
Joined: Tue Mar 28, 2017 8:03 pm

Re: ESP32 memmem?

Postby jcsbanks » Mon Jun 17, 2019 8:47 am

I appended this to component.mk to use memmem:

Code: Select all

#used for memmem
CFLAGS += -D__GNU_VISIBLE

Who is online

Users browsing this forum: No registered users and 84 guests