Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By martinayotte
#47974 The file /.arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi/src/ESP8266WiFiScan.h will show you that :

Code: Select allString SSID(uint8_t networkItem);

Code: Select allint32_t RSSI(uint8_t networkItem);


I still don't understand why you have compile errors since I'm doing quite the same thing without any casts :

Code: Select all    int n = WiFi.scanNetworks();
    for (int i = 0; i < n; i++) {
      Serial.print(WiFi.SSID(i));
      Serial.print(" / ");
      Serial.println(WiFi.RSSI(i));
    }
User avatar
By Mingy
#47979 Sorry about dribbling this out. I have looked into the issue of
"The second issue with strdup() reveal that there something wrong with your environment, because it is part of following file of the core : .arduino15/packages/esp8266/hardware/esp8266/2.2.0/cores/esp8266/libc_replacements.c"

EclipseArduino duplicates esp8266/2.2.0 and its version of libc_replacements.c is identical to that of the Arduino IDE.

I focused on strdup() because at least I know a lot moe c than c++ and the issues are probably related. I discovered that the prototype is

#if !defined(__STRICT_ANSI__) || (_XOPEN_SOURCE >= 500)
char *_EXFUN(strdup,(const char *));
#endif

If I put
extern char *strdup(const char *);

In my program, the error goes away.

It seems that eclipse defines __STRICT_ANSI__ but I can't modify that definition. The compiler log shows

"C:\eclipseArduino\arduinoPlugin\tools\esp8266\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ " etc.

ie. "C:\eclipseArduino\arduinoPlugin\tools\esp8266\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/include" "-IC:/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/lwip/include" -c -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DARDUINO=10606 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 -DESP8266 -I"C:\eclipseArduino\arduinoPlugin\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266" -I"C:\eclipseArduino\arduinoPlugin\packages\esp8266\hardware\esp8266\2.2.0\variants\d1_mini" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "../.ino.cpp" -o ".ino.cpp.o" -Wall


suggesting the compiler is "undefining" __STRICT_ANSI__ I can't find a place where _XOPEN_SOURCE is defined or how I could define it.

I have not yet determined if this is related to the WiFi.RSSI(i), etc., problems

Thanks again for the help
User avatar
By jcmvbkbc
#47980
Mingy wrote:"C:\eclipseArduino\arduinoPlugin\tools\esp8266\xtensa-lx106-elf-gcc\1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-IC:/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/include" "-IC:/eclipseArduino/arduinoPlugin/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/lwip/include" -c -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -DF_CPU=80000000L -DARDUINO=10606 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 -DESP8266 -I"C:\eclipseArduino\arduinoPlugin\packages\esp8266\hardware\esp8266\2.2.0\cores\esp8266" -I"C:\eclipseArduino\arduinoPlugin\packages\esp8266\hardware\esp8266\2.2.0\variants\d1_mini" -MMD -MP -MF".ino.cpp.d" -MT".ino.cpp.o" -D__IN_ECLIPSE__=1 -x c++ "../.ino.cpp" -o ".ino.cpp.o" -Wall

Try -std=gnu++11 instead of -std=c++11 , this should suppress definition of __STRICT_ANSI__.