How to fix ESP32 error: 'gpio_num_t' does not name a type

Problem:

When compiling an ESP32 project, you may encounter the following error message:

gpio_include_fix.cpp
include/Pins.hpp:10:11: error: 'gpio_num_t' does not name a type
 constexpr gpio_num_t Pin_WS2812_Data = GPIO_NUM_37;

Solution

You just need to include hal/gpio_types.h before the first use of gpio_num_t in the file (typically, at the top of the file where the other includes are located):

include_gpio_types_example.cpp
#include <hal/gpio_types.h>

Check out similar posts by category: ESP32, C/C++