ESP32 WiFi Library Compilation Error: 'network_event_handle_t' does not name a type

Problem Summary

I'm getting compilation errors when trying to compile a simple WiFi sketch for ESP32 using Arduino IDE 2.3.6. The error involves missing type definitions in the WiFi library, specifically network_event_handle_t and related Arduino event types.

Environment Details

  • Arduino IDE Version: 2.3.6
  • ESP32 Board Package: Tried multiple 3.x versions (3.0.0, 3.1.3, 3.2.0) -> Version 2.0.17 works fine
  • Target Board: ESP32-C6 (requires 3.x package versions)
  • Operating System: Windows

Minimal Code That Fails to Compile

#include <WiFi.h>

void setup() {
  Serial.begin(115200);
  WiFi.begin("yourSSID", "yourPassword");
}

void loop() {
}

Error Messages

In file included from C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiSTA.h:30,
                 from C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFi.h:34,
                 from C:\Users\Muddyblack\Downloads\hexxaBB\microcontroller\microcontroller.ino:1:
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:49:25: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
   49 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:85:3: note: in expansion of macro 'wifi_event_id_t'
   85 |   wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:49:25: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
   49 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:86:3: note: in expansion of macro 'wifi_event_id_t'
   86 |   wifi_event_id_t onEvent(WiFiEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:49:25: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
   49 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:87:3: note: in expansion of macro 'wifi_event_id_t'
   87 |   wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |   ^~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:46:25: error: 'NetworkEventCb' has not been declared
   46 | #define WiFiEventCb     NetworkEventCb
      |                         ^~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:88:20: note: in expansion of macro 'WiFiEventCb'
   88 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                    ^~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:88:41: error: 'arduino_event_id_t' has not been declared
   88 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                         ^~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:48:25: error: 'NetworkEventSysCb' has not been declared
   48 | #define WiFiEventSysCb  NetworkEventSysCb
      |                         ^~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:89:20: note: in expansion of macro 'WiFiEventSysCb'
   89 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                    ^~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:89:44: error: 'arduino_event_id_t' has not been declared
   89 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                            ^~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:89:8: error: 'void WiFiGenericClass::removeEvent(int, int)' cannot be overloaded with 'void WiFiGenericClass::removeEvent(int, int)'
   89 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |        ^~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:88:8: note: previous declaration 'void WiFiGenericClass::removeEvent(int, int)'
   88 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |        ^~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:49:25: error: 'network_event_handle_t' has not been declared
   49 | #define wifi_event_id_t network_event_handle_t
      |                         ^~~~~~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:90:20: note: in expansion of macro 'wifi_event_id_t'
   90 |   void removeEvent(wifi_event_id_t id);
      |                    ^~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:134:25: error: 'arduino_event_id_t' has not been declared
  134 |   const char *eventName(arduino_event_id_t id);
      |                         ^~~~~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:136:30: error: 'arduino_event_t' has not been declared
  136 |   static void _eventCallback(arduino_event_t *event);
      |                              ^~~~~~~~~~~~~~~
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:88:68: error: 'ARDUINO_EVENT_MAX' was not declared in this scope; did you mean 'WIFI_EVENT_MAX'?
   88 |   void removeEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                                                    ^~~~~~~~~~~~~~~~~
      |                                                                    WIFI_EVENT_MAX
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiGeneric.h:89:71: error: 'ARDUINO_EVENT_MAX' was not declared in this scope; did you mean 'WIFI_EVENT_MAX'?
   89 |   void removeEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX);
      |                                                                       ^~~~~~~~~~~~~~~~~
      |                                                                       WIFI_EVENT_MAX
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiSTA.h:45:42: error: expected class-name before '{' token
   45 | class STAClass : public NetworkInterface {
      |                                          ^
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiSTA.h:98:3: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
   98 |   network_event_handle_t _wifi_sta_event_handle;
      |   ^~~~~~~~~~~~~~~~~~~~~~
      |   network_prov_event_handler_t
In file included from C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFi.h:35:
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiAP.h:40:41: error: expected class-name before '{' token
   40 | class APClass : public NetworkInterface {
      |                                         ^
C:\Users\Muddyblack\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.2.0\libraries\WiFi\src/WiFiAP.h:63:3: error: 'network_event_handle_t' does not name a type; did you mean 'network_prov_event_handler_t'?
   63 |   network_event_handle_t _wifi_ap_event_handle;
      |   ^~~~~~~~~~~~~~~~~~~~~~
      |   network_prov_event_handler_t
exit status 1

Compilation error: exit status 1

What I've Tried

  1. Downgraded to ESP32 package 2.0.17 - This works but doesn't support ESP32-C6
  2. Complete reinstallation - Deleted and reinstalled Arduino IDE and all packages
  3. Tested multiple ESP32 3.x versions - Same error across 3.0.0, 3.1.0, and 3.2.0
  4. Verified it worked previously - This exact setup worked until yesterday evening

Specific Questions

So why does it appear it worked just fine yesterday and then my IDE just did a reset and bam it did not work anymore idk maybe i clicked any update button but still weird it worked with esp32 wroom-32D and esp32 c6 mini pretty fine ... just didnt look up at that time what version i had installed but i guess it must had been also 3.2.0!

I hope someone can help me out.

Hi @muddyblack. I'm going to ask you to provide the full verbose output from a compilation.


:red_exclamation_mark: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Check the box next to "Show verbose output during: ☐ compile" in the "Preferences" dialog.
  3. Click the "OK" button.
    The "Preferences" dialog will close.
  4. Select Sketch > Verify/Compile from the Arduino IDE menus.
  5. Wait for the compilation to fail.
  6. You will see a "Compilation error: ..." notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  7. Open a reply here on this forum topic by clicking the "Reply" button.
  8. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
  9. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the compilation output into the code block.
  10. Move the cursor outside of the code block markup before you add any additional text to your reply.
  11. Click the "Reply" button to publish the post.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a reply here on this forum topic by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

hey thank you for the detailed response i just tested the minni script above with all the rest of my project i thought it would only compile that part but it compiled still from what i see in the logs now sorry for that i tried it in an extra arduino winow there it compiled :sweat_smile:
So I must do sth wrong in my big project, but still confuses me that it worked yesterday with the same script haha :confused:

I only have all imports in the main file but I think that is normal no? I dont need to include in every other ino file i create?
I have:
#include <WiFi.h>
#include <WebServer.h>
#include <EEPROM.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <DNSServer.h>

here the file:
verbose_error.txt (129,3 KB)

10 hours of debugging because I named my files network.h and network.ino renaming them fixed it :skull:

Thank your for the info with verbose compiling!

1 Like

but still confuses me that it worked yesterday with the same script

It doesn't solve your problem, but I sometimes encounter weird problems that doesn't make any sense. Mostly after the Arduino is powered off for a few days. The only thing I have to do then is re-upload the exact same program, and everything works fine.

For your problem, I have had the same shit because there were two Arduino windows running on my computer. It was something with the virtual port assignment that got confused, but it doesn't sound like that's your case. I would suggest (a very invasive method) deleting every file that is slightly connected to the Arduino IDE. And download everything again. That worked for me last time I encountered an unexplainable bug. But only do it as a last resort. Another thing I discovered then is that you also need to have the Arduino IDE 1.8 for some Wi-Fi libraries in order to compile properly. Is it possible that they got deleted during the unexpected reboot?

Great work of finding the cause of the problem!

Specifically, it was the presence of a file named network.h in the sketch that caused the compilation to fail. The .ino filename is not a factor.

The developers of the "esp32" boards platform did a non-standard thing by configuring the templates from which Arduino IDE generates to the compilation commands so that the sketch folder is added to the compiler's "search path". The "WiFi" library contains an #include directive for a file named Network.h. The targeted file is the one in the "Networking" library:

Even though the two files have different names, on Windows machines (where the filesystem is case-insensitive) the compiler does not treat the filenames as case sensitive. Because of the way the "esp32" platform developers configured the compilation command, the file in the sketch folder is given priority over the one in the "Networking" library and so the file from the sketch is used instead of the intended one. This results in the declarations that are provided by the "Networking" library's Network.h being missing, and thus any code in the "WiFi" library that relies on those declarations to fail to compile.

The fault can indeed be reproduced by the minimal sketch you provided in post #1, or even with this even more minimal sketch:

#include <WiFi.h>
void setup() {}
void loop() {}

However, it is necessary to add a file named network.h to the sketch, and to compile it on a Windows or macOS machine (these both have case-insensitive filesystems, but Linux does not) .