Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By synslash
#13290 I know hardware, but as a programmer i'm a bumbler that eventually gets the job done.
I'm trying to port a sketch I wrote for Arduino that parses a char array from a pseudoNMEA format $xxx,x,x,x,x,x into individual string variables to be processed. For this I use the strtok_r function. As of now the only thing not compiling in my sketch is this function giving me the following output which i take as "unrecognized function".

"error: 'strtok_r' was not declared in this scope"

The non reentrant strtok wihtout the "_r" works as expected. As far as I know strtok_r is in the espressif SDK. I realize programming the ESP8266 in arduino is new and there will be issues. Would this missing variant of a command be a bug, or just a missing feature? Thanks
User avatar
By synslash
#13316 As I've said I'm not the greatest programmer, however, would I be wrong in saying that if I were declaring strtok_r() within my program that I should have the workings of that function within my program aswell? I am not looking to write the function myself but use the function which should be part of the sdk. just as delay() or Serial.print() would be called.

I looked though the espressive IoT SDK and found several mentions of strtok_r. I tried adding that include file (esp_libc.h) and my error then changed to the following. I can't explain why this is happening, all i can do is blame it on my lack of experience but I've used this function in arduino and c++ without issue in the past.

[i][i]Arduino: 1.6.1 (Windows 7), Board: "Generic ESP8266 board"

UdpServer_parse.cpp.o: In function `setup':

UdpServer_parse.cpp:(.text+0x164): undefined reference to `strtok_r(char*, char const*, char**)'

UdpServer_parse.cpp:(.text+0x1bf): undefined reference to `strtok_r(char*, char const*, char**)'

collect2.exe: error: ld returned 1 exit status

Error compiling.
[/i][/i]
User avatar
By synslash
#13408 The problem turned out to be lack of information. After combing the forum I found I was including the external header file "esp_libc.h" incorrectly. I was doing it the same way you typically would in arduino by simply using

#include "esp_libc.h"

This would give me the error i showed above. Turns out I had to use the following

extern "C" {
#include "esp_libc.h"
}


Feel free to move this thread to a more suitable section as it's clearly not a bug and just user error. Thanks