using <cstring> header in IDF v4.1

kluverp
Posts: 26
Joined: Mon Jun 18, 2018 7:08 am

using <cstring> header in IDF v4.1

Postby kluverp » Tue Nov 03, 2020 12:24 pm

Hi all,

The search is broken on this site, so I was unable to seach for this question.

I have a ESP32 C++ project, running on IDF version 4.1.

When I include the <cstring> header like so:

Code: Select all

#include <cstring>

/**
 * Main entry point application
 */
void app_main()
{
	char foo[100];
	strncpy(foo, "test", sizeof(foo));
}
I get the following errors:

Code: Select all

In file included from /home/peter/esp/levelmeasurement/main/main.cpp:24:
/home/peter/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstring:75:11: error: '::memchr' has not been declared
   using ::memchr;
           ^~~~~~
/home/peter/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstring:76:11: error: '::memcmp' has not been declared
   using ::memcmp;
           ^~~~~~
/home/peter/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstring:77:11: error: '::memcpy' has not been declared
   using ::memcpy;
           ^~~~~~
/home/peter/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstring:78:11: error: '::memmove' has not been declared
   using ::memmove;
           ^~~~~~~
/home/peter/.espressif/tools/xtensa-esp32-elf/esp-2020r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/8.2.0/cstring:79:11: error: '::memset' has not been declared
   using ::memset;
   
   ... etc.
What am I doing wrong here?

I also tried including just "string.h", but that causes it to say:

Code: Select all

'strncpy' is defined in header '<cstring>'; did you forget to '#include <cstring>'?

kluverp
Posts: 26
Joined: Mon Jun 18, 2018 7:08 am

Re: using <cstring> header in IDF v4.1

Postby kluverp » Tue Nov 03, 2020 12:58 pm

Found the issue myself...

Silly mistake. I had a component with a file called "string.h". That is not a good idea...

Who is online

Users browsing this forum: No registered users and 227 guests