esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.09k stars 13.33k forks source link

espconn.h - conflicting declaration of dns_found_callback #9056

Open vgahlaut opened 11 months ago

vgahlaut commented 11 months ago

Basic Infos

Platform

Settings in IDE

Problem Description

Detailed problem description goes here.

If we include sdk espconn.h in our code. It gets conflicting type of dns_found_callback during compilation. Compilation error and sketch are provided to reproduce problem.

Request you to please suggest some workaround to get over this issue.

MCVE Sketch


extern "C"{
    // Platform Includes
    #include <espconn.h>
}

#include <ESP8266WiFi.h>

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(115200);
  WiFi.begin((char*)"testssid", (char*)"testpassword");
}
void loop() {

}

Debug Messages

In file included from C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src/ESP8266WiFiGeneric.h:29,
                 from C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src/ESP8266WiFiSTA.h:28,
                 from C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2\libraries\ESP8266WiFi\src/ESP8266WiFi.h:34,
                 from C:\Users\vipin\Desktop\dns_found_cb_reproducer\dns_found_cb_reproducer.ino:16:
C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2/tools/sdk/lwip2/include/lwip/dns.h:103:16: error: conflicting declaration 'typedef void (* dns_found_callback)(const char*, const ip_addr_t*, void*)'
  103 | typedef void (*dns_found_callback)(const char *name, const ip_addr_t *ipaddr, void *callback_arg);
      |                ^~~~~~~~~~~~~~~~~~
In file included from C:\Users\vipin\Desktop\dns_found_cb_reproducer\dns_found_cb_reproducer.ino:13:
C:\Users\vipin\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.1.2/tools/sdk/include/espconn.h:447:16: note: previous declaration as 'typedef void (* dns_found_callback)(const char*, ip4_addr_t*, void*)'
  447 | typedef void (*dns_found_callback)(const char *name, ipv4_addr_t *ipaddr, void *callback_arg);
mcspr commented 11 months ago

Was previously mentioned in https://github.com/esp8266/Arduino/issues/8920#issuecomment-1539965172 You could follow the comment suggestion and delete the conflicting typedef line from espconn.h

I wonder if we should just rename dns_found_callback inside of espconn.h to something like espconn_dns_found_callback (assuming espconn actually still works)