espressif / esp-now

A connectionless Wi-Fi communication protocol
Apache License 2.0
526 stars 93 forks source link

Incompatible format error in espnow components (AEGHB-256) #77

Closed horsemann07 closed 1 year ago

horsemann07 commented 1 year ago

Hi developers,

I encountered an error while using espnow on esp-idf v5.0.2. Previously, on esp-idf 4.4.4, the build process worked perfectly. However, with the latest version, I am facing the following error:

../../../components/esp_hw_support/include/esp_mac.h:14:16: error: format '%x' expects argument of type 'unsigned int *', but argument 7 has type 'uint32_t *' {aka 'long unsigned int *'} [-Werror=format=]
   14 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../components/utils/src/espnow_utils.c:68:31: note: in expansion of macro 'MACSTR'
   68 |     int ret = sscanf(mac_str, MACSTR, mac_data, mac_data + 1, mac_data + 2,
      |                               ^~~~~~
../../../components/esp_hw_support/include/esp_mac.h:14:40: note: format string is defined here
   14 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
      |                                     ~~~^
      |                                        |
      |                                        unsigned int *
      |                                     %02lx
../../../components/esp_hw_support/include/esp_mac.h:14:16: error: format '%x' expects argument of type 'unsigned int *', but argument 8 has type 'uint32_t *' {aka 'long unsigned int *'} [-Werror=format=]
   14 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../components/utils/src/espnow_utils.c:68:31: note: in expansion of macro 'MACSTR'
   68 |     int ret = sscanf(mac_str, MACSTR, mac_data, mac_data + 1, mac_data + 2,
      |                               ^~~~~~
../../../components/esp_hw_support/include/esp_mac.h:14:45: note: format string is defined here
   14 | #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
      |                                          ~~~^
      |                                             |
      |                                             unsigned int *

One potential solution is to modify the appropriate format specifier to match the correct data type. However, this approach might require additional time and effort. It would be helpful to know if there is a way to disable the checking of this particular format to proceed with the build process.

lhespress commented 1 year ago

@horsemann07 I also suggest modify the appropriate format specifier to match the correct data type.