espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.29k stars 7.2k forks source link

Getting compiler errors with snmp.h (IDFGH-12578) #13580

Open 0xFEEDC0DE64 opened 5 months ago

0xFEEDC0DE64 commented 5 months ago

Using latest master of esp-idf,

I get compiler errors when including lwip/apps/snmp.h:

<firmware-path>/esp-idf/components/lwip/include/apps/esp_sntp.h:287:9: error: 'uint8_t sntp_getreachability(uint8_t)' was declared 'extern' and later 'static' [-fpermissive]
  287 | uint8_t sntp_getreachability(uint8_t idx)
      |         ^~~~~~~~~~~~~~~~~~~~
<firmware-path>/esp-idf/components/lwip/lwip/src/include/lwip/apps/sntp.h:62:6: note: previous declaration of 'u8_t sntp_getreachability(u8_t)'
   62 | u8_t sntp_getreachability(u8_t idx);
      |      ^~~~~~~~~~~~~~~~~~~~
<firmware-path>/esp-idf/components/lwip/include/apps/esp_sntp.h:293:26: error: conflicting declaration of C function 'esp_sntp_operatingmode_t sntp_getoperatingmode()'
  293 | esp_sntp_operatingmode_t sntp_getoperatingmode(void)
      |                          ^~~~~~~~~~~~~~~~~~~~~
<firmware-path>/esp-idf/components/lwip/lwip/src/include/lwip/apps/sntp.h:52:6: note: previous declaration 'u8_t sntp_getoperatingmode()'
   52 | u8_t sntp_getoperatingmode(void);
      |      ^~~~~~~~~~~~~~~~~~~~~
david-cermak commented 5 months ago

Hi @0xFEEDC0DE64

This is probably a regression from c30f2825d5 (added a forwarding layer for some potentially thread unsafe lwip API to espressif wrappers). This is probably causing trouble when building your project with some custom lwip features (not selected by Kconfig options), I wasn't able to reproduce it, though. I'd like to know how you're building and enabling the SNMP module.

We protect this compat layer with ESP_LWIP_COMPONENT_BUILD macro, so it's not taken into account when building lwip component. I guess you can workaround this issue by defining this macro for the component using SNMP (or adding the SNMP build to the lwip library). Adding this line to the component makefile (maybe main component?) may fix the issue:

    target_compile_definitions(${COMPONENT_LIB} PRIVATE ESP_LWIP_COMPONENT_BUILD)
david-cermak commented 3 months ago

@0xFEEDC0DE64 Could you please share more details on how you're building your project with snmp module?

this seems unrelated to c30f2825d554dfe25afa450bb6aaa3aeb58782ef since you're also getting errors on sntp_getoperatingmode() API