invalid conversion from 'ip4_addr*' to 'ip_addr*' [-fpermissive]

Hello,

hope someboby can give a hint ...

I wrote the following Code about 18 month ago. I'm quite sure it worked, but after updating several parts of the Arduino IDE, I get the following Error:

web:270: error: invalid conversion from 'ip4_addr*' to 'ip_addr*' [-fpermissive]

IPaddress = &stat_info->ip;

What's the Problem, what has changed?

...
  struct      station_info *stat_info;
  struct      ip_addr *IPaddress;
...
if ( (WiFi.getMode() == WIFI_AP) or (WiFi.getMode() == WIFI_AP_STA) )
  {
    softap_stations_cnt = WiFi.softAPgetStationNum();                           // number of stations which are connected to ESP8266 soft-AP
    strcat( pBuff , "IP-Adr ..... : " );
    strcat( pBuff , ipToString( WiFi.softAPIP() ).c_str() );
    strcat( pBuff , "
" ); 
    strcat( pBuff , "MAC-Adr .... : " );
    strcat( pBuff , macToString(WiFi.softAPmacAddress(apMacAddr)).c_str() );
    strcat( pBuff , "
" );
    strcat( pBuff , String( softap_stations_cnt ).c_str() );
    strcat( pBuff , " Connected Clients: 
" );
     
    Serial.println("Softap Station Count: " + softap_stations_cnt);
    stat_info = wifi_softap_get_station_info();
    while (stat_info != NULL) 
      {
        IPaddress = &stat_info->ip;
        uintaddress = IPaddress->addr;
        Serial.print( ipToString(uintaddress) );
        strcat( pBuff , ipToString(uintaddress).c_str() ); 
        strcat( pBuff , " - " );
        strcat( pBuff , macToString(stat_info->bssid).c_str() );
        stat_info = STAILQ_NEXT(stat_info, next);
      }
    wifi_softap_free_station_info();
     } else {
...

Update:
Compiling for WEMOS D1 mini Pro

snaudi:
What's the Problem

Well, for one thing, you haven't shown us what the station_info and ip_addr structs look like.

Or, told us what processor you're compiling for.

http://snippets-r-us.com

Newer ide forces the compiler to be more strictly. If you are sure the two structs are compatible, try to explicitly cast it.

Sorry, Im compiling for WEMOS D1 mini Pro.

Here is the demo code, as I don’t want to post the complete original code.

It get the same error:

“C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9/bin/xtensa-lx106-elf-g++” -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/sdk/include” “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/sdk/lwip2/include” “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/sdk/libc/xtensa-lx106-elf/include” “-IC:\Users\MiKo\AppData\Local\Temp\arduino_build_848847/core” -c -w -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections -fno-exceptions -DNONOSDK221=1 -DF_CPU=80000000L -DLWIP_OPEN_SRC -DTCP_MSS=536 -DLWIP_FEATURES=1 -DLWIP_IPV6=0 -DARDUINO=10805 -DARDUINO_ESP8266_WEMOS_D1MINIPRO -DARDUINO_ARCH_ESP8266 -DARDUINO_BOARD=“ESP8266_WEMOS_D1MINIPRO” -DFLASHMODE_DIO -DESP8266 “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\cores\esp8266” “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\variants\d1_mini” “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi\src” “-IC:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WebServer\src” “C:\Users\MiKo\AppData\Local\Temp\arduino_build_848847\sketch\esp_test_wifi-client-info.ino.cpp” -o “C:\Users\MiKo\AppData\Local\Temp\arduino_build_848847\sketch\esp_test_wifi-client-info.ino.cpp.o”
D:\Dokumente\Arduino\ESP8266\esp_test_wifi-client-info\esp_test_wifi-client-info.ino: In function ‘void client_status()’:

esp_test_wifi-client-info:39: error: invalid conversion from ‘ip4_addr*’ to ‘ip_addr*’ [-fpermissive]

IPaddress = &stat_info->ip;

^

Bibliothek ESP8266WiFi in Version 1.0 im Ordner: C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WiFi wird verwendet
Bibliothek ESP8266WebServer in Version 1.0 im Ordner: C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2\libraries\ESP8266WebServer wird verwendet
exit status 1
invalid conversion from ‘ip4_addr*’ to ‘ip_addr*’ [-fpermissive]

I’ve borrowed this demo Code from this Link: https://mybtechprojects.tech

//Header Files
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
 
//Header File to get information about client
extern "C" {
#include<user_interface.h>
}
 
//Hotspot Name and Password
const char* ssid = "ESPWebServer";
const char* password = "12345678";
 
ESP8266WebServer server(80); //Server on port 80
 
void handleRoot() {
  server.send(200, "text/plain", "Thank You for using www.mybtechprojects.tech");
}
 
void client_status()
{
 
unsigned char number_client;
struct station_info *stat_info;
 
struct ip_addr *IPaddress;
IPAddress address;
int i=1;
 
number_client= wifi_softap_get_station_num();
stat_info = wifi_softap_get_station_info();
 
Serial.print(" Total connected_client are = ");
Serial.println(number_client);
 
while (stat_info != NULL) {
 
IPaddress = &stat_info->ip;
address = IPaddress->addr;
 
Serial.print("Client  =  ");
 
Serial.print(i);
Serial.println();
Serial.print(" Ip adress is =   ");
Serial.println((address));
Serial.print("Mac adress is =   ");
 
Serial.print(stat_info->bssid[0],HEX);
Serial.print(stat_info->bssid[1],HEX);
Serial.print(stat_info->bssid[2],HEX);
Serial.print(stat_info->bssid[3],HEX);
Serial.print(stat_info->bssid[4],HEX);
Serial.println(stat_info->bssid[5],HEX);
 
stat_info = STAILQ_NEXT(stat_info, next);
i++;
Serial.println();
 
}
delay(500);
}
 
 
void setup(){
  Serial.begin(9600);
  Serial.println("");
  WiFi.mode(WIFI_AP); 
 
  //For WI-FI with Password.     
  WiFi.softAP(ssid,password);
  //For WI-FI without Password  
  // WiFi.softAP(ssid);
 
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("HotSpot IP:");
  Serial.println(myIP);
 
  server.on("/", handleRoot);      
 
  server.begin();                 
  Serial.println("HTTP server started");
}
 
void loop()
{
  client_status();
  server.handleClient();          
}

I’ve borrowed this demo Code from this Link: https://mybtechprojects.tech

arduino_new:
Newer ide forces the compiler to be more strictly. If you are sure the two structs are compatible, try to explicitly cast it.

Can you provide example?

Try:

ipv4_addr *IPaddress;

snaudi:
Can you provide example?

IPaddress = (ip_addr *)&stat_info->ip;

Some cores compile with -fpermissive which makes those sort of "dirty" implicit casts into warnings instead of errors. But most do not.

Thx to everybody, but most to gfvalvo

gfvalvo:
Try:

ipv4_addr *IPaddress;

Changing my code to

struct      ipv4_addr *IPaddress;

fixed this Problem !

The "struct" is superfluous. You don't need it:

~~struct ~~ipv4_addr *IPaddress;

Thank you again, gfvalvo!

But now the IDE Returns following output:

Der Sketch verwendet 391012 Bytes (37%) des Programmspeicherplatzes. Das Maximum sind 1044464 Bytes.
Globale Variablen verwenden 45888 Bytes (56%) des dynamischen Speichers, 36032 Bytes für lokale Variablen verbleiben. Das Maximum sind 81920 Bytes.
C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\tools\python\3.7.2-post1/python C:\Users\MiKo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py --chip esp8266 --port COM10 --baud 921600 --trace version --end --chip esp8266 --port COM10 --baud 921600 --trace write_flash 0x0 C:\Users\MiKo\AppData\Local\Temp\arduino_build_756905/THP-Sender-Full_v002_01_f_r_Demo-Box.ino.bin --end
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM10
Connecting...TRACE +0.000 command op=0x08 data len=36 wait_response=1 timeout=0.100 data=
0707122055555555 5555555555555555 | ... UUUUUUUUUUUU
5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
55555555 | UUUU
TRACE +0.000 Write 46 bytes:
c000082400000000 0007071220555555 | ...$........ UUU
5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
5555555555555555 5555555555c0 | UUUUUUUUUUUUU.
TRACE +0.103 Timed out waiting for packet header
.TRACE +0.056 command op=0x08 data len=36 wait_response=1 timeout=0.100 data=
0707122055555555 5555555555555555 | ... UUUUUUUUUUUU
5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
55555555 | UUUU
TRACE +0.000 Write 46 bytes:
c000082400000000 0007071220555555 | ...$........ UUU
5555555555555555 5555555555555555 | UUUUUUUUUUUUUUUU
5555555555555555 5555555555c0 | UUUUUUUUUUUUU.
TRACE +0.014 Read 1 bytes: c0
TRACE +0.000 Read 95 bytes:
0108020007071220 0000c0c001080200 | ....... ........
070712200000c0c0 0108020007071220 | ... ...........
0000c0c001080200 070712200000c0c0 | ........... ....
0108020007071220 0000c0c001080200 | ....... ........
070712200000c0c0 0108020007071220 | ... ...........
0000c0c001080200 070712200000c0 | ........... ...
TRACE +0.001 Received full packet: 01080200070712200000
TRACE +0.004 Received full packet: 01080200070712200000
TRACE +0.003 Received full packet: 01080200070712200000
TRACE +0.004 Received full packet: 01080200070712200000
TRACE +0.003 Received full packet: 01080200070712200000

... many, many pages ...

Leaving...
TRACE +0.005 command op=0x02 data len=16 wait_response=1 timeout=3.000 data=00000000000000000040000000000000
TRACE +0.001 Write 26 bytes:
c000021000000000 0000000000000000 | ................
0000400000000000 00c0 | ..@.......
TRACE +0.001 Read 1 bytes: c0
TRACE +0.001 Read 11 bytes: 01020200000000000000c0
TRACE +0.000 Received full packet: 01020200000000000000
TRACE +0.005 command op=0x12 data len=4 wait_response=1 timeout=3.000 data=01000000
TRACE +0.000 Write 14 bytes: c0001204000000000001000000c0
TRACE +0.001 Read 1 bytes: c0
TRACE +0.001 Read 11 bytes: 01120200000000000000c0
TRACE +0.000 Received full packet: 01120200000000000000
Hard resetting via RTS pin...

So compilation seems to be successfull, but what happens after that?

Odd, don't know. Use what works, I guess.

Nothing works - I just don't get the original compiling error anymore,
with or without the "struct".
But the following trace appears with both ways …

I guess you've moved on to the next step of debugging. This compile error seems fixed, now you have to make it work. I don't have your hardware. Good luck.