Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Error when compiling sketch (strtok_r)

Open marcoschwartz opened this issue 11 years ago • 10 comments

Hello,

Since the last commit (ec4f53e70508018a1ec644333f4a8045db7eb29f) I have an error with a sketch that was working before:

/Users/marco/Downloads/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/libc_replacements.c: At top level: /Users/marco/Downloads/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/libc_replacements.c:166:25: error: conflicting types for 'strtok_r' char* ICACHE_FLASH_ATTR strtok_r(char * str, const char * delimiters, char ** temp) { ^ /Users/marco/Downloads/Arduino/build/macosx/work/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/libc_replacements.c:163:12: note: previous implicit declaration of 'strtok_r' was here return strtok_r(str, delimiters, NULL); ^ Error compiling.

Any idea about this issue? Thanks

marcoschwartz avatar Apr 19 '15 08:04 marcoschwartz

can you test the fix above?

Links2004 avatar Apr 19 '15 08:04 Links2004

I just tried the fix, same error.

marcoschwartz avatar Apr 19 '15 08:04 marcoschwartz

can you provide an example, I don't get the error reproduced.

Links2004 avatar Apr 19 '15 08:04 Links2004

I get the error with my aREST library that implements a REST interface for the chip. You can find the example here:

https://github.com/marcoschwartz/aREST/tree/master/examples/ESP8266

marcoschwartz avatar Apr 19 '15 08:04 marcoschwartz

is working fine. only one error

../ESP8266_aREST.ino:42:23: error: 'ledControl' was not declared in this scope
   rest.function("led",ledControl);

i command it out and than it compile.

i only wondering why the implementation is in the .h file and there is no .cpp file for the library?

Links2004 avatar Apr 19 '15 17:04 Links2004

After pulling the latest, running ant clean and ant dist I get the same error on the mDNS example sketch.

See if this pull request fixes it for you, it did for me.

https://github.com/esp8266/Arduino/pull/89

gregslomin avatar Apr 20 '15 06:04 gregslomin

I have the same error as marcoschwartz: .pioenvs\esp01_8266\FrameworkArduino\libc_replacements.c: In function 'strtok': .pioenvs\esp01_8266\FrameworkArduino\libc_replacements.c:164:5: warning: return makes pointer from integer without a cast [enabled by default] return strtok_r(str, delimiters, NULL); ^ .pioenvs\esp01_8266\FrameworkArduino\libc_replacements.c: At top level: .pioenvs\esp01_8266\FrameworkArduino\libc_replacements.c:167:25: error: conflicting types for 'strtok_r' char* ICACHE_FLASH_ATTR strtok_r(char * str, const char * delimiters, char ** temp) { ^ .pioenvs\esp01_8266\FrameworkArduino\libc_replacements.c:164:12: note: previous implicit declaration of 'strtok_r' was here return strtok_r(str, delimiters, NULL);

valeros avatar Apr 20 '15 06:04 valeros

I also have the same error as marcoschwartz after doing a clean build. The gregslomin fix works for me.

jeffryr avatar Apr 20 '15 11:04 jeffryr

Just tried again with my aREST library + the gregslomin fix, now it works for me as well.

marcoschwartz avatar Apr 20 '15 12:04 marcoschwartz

merged the fix in 2edc522, thanks!

igrr avatar Apr 21 '15 12:04 igrr