compiler bug, occures in "hal/pcnt_ll.h" - Expresion regarded as CONST ?

ESPI_1
Posts: 10
Joined: Thu Feb 27, 2020 7:08 am

compiler bug, occures in "hal/pcnt_ll.h" - Expresion regarded as CONST ?

Postby ESPI_1 » Sun Mar 01, 2020 9:14 am

simply add #include "driver/pcnt.h" in my Project

causes two Compiler-Problems in "hal/pcnt_ll.h" line 48 and in line 60 (see Code below)

C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:48:71: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed

I cannot see why the Compiler does not understand this original espressif Code
- seems to be a Compiler Bug: - Looks like he regards the struct as CONST


I have also added my BugFix

I am using the latest Eclipse-plugin, Installed 4 Days ago
- Espressif IDF Plugins for Eclipse 1.0.0.202002201116 com.espressif.idf.feature.feature.group ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD

  1. /**
  2.  * @brief Set PCNT counter mode
  3.  *
  4.  * @param hw Peripheral PCNT hardware instance address.
  5.  * @param unit PCNT unit number
  6.  * @param channel PCNT channel number
  7.  * @param pos_mode Counter mode when detecting positive edge
  8.  * @param neg_mode Counter mode when detecting negative edge
  9.  * @param hctrl_mode Counter mode when control signal is high level
  10.  * @param lctrl_mode Counter mode when control signal is low level
  11.  */
  12. static inline void pcnt_ll_set_mode(pcnt_dev_t *hw, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
  13. {
  14. //    typeof(hw->conf_unit[unit].conf0) conf0_reg = hw->conf_unit[unit].conf0; //C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:48:71: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed union>'
  15. //    if (channel == 0) {
  16. //        conf0_reg.ch0_pos_mode = pos_mode;
  17. //        conf0_reg.ch0_neg_mode = neg_mode;
  18. //        conf0_reg.ch0_hctrl_mode = hctrl_mode;
  19. //        conf0_reg.ch0_lctrl_mode = lctrl_mode;
  20. //    } else {
  21. //        conf0_reg.ch1_pos_mode = pos_mode;
  22. //        conf0_reg.ch1_neg_mode = neg_mode;
  23. //        conf0_reg.ch1_hctrl_mode = hctrl_mode;
  24. //        conf0_reg.ch1_lctrl_mode = lctrl_mode;
  25. //    }
  26. //    hw->conf_unit[unit].conf0 = conf0_reg; //C:/Users/.../esp_idf_Tools_V2_2/components/soc/src/esp32/include/hal/pcnt_ll.h:60:33: error: cannot bind rvalue reference of type 'pcnt_dev_s::<unnamed struct>::<unnamed union>&&' to lvalue of type 'volatile pcnt_dev_s::<unnamed struct>::<unnamed union>'
  27.  
  28. //My Bugfix for the moment
  29.     typeof(hw->conf_unit[unit].conf0)* lConf0RegPtr = &hw->conf_unit[unit].conf0;
  30.     if (channel == 0) {
  31.         lConf0RegPtr->ch0_pos_mode = pos_mode;
  32.         lConf0RegPtr->ch0_neg_mode = neg_mode;
  33.         lConf0RegPtr->ch0_hctrl_mode = hctrl_mode;
  34.         lConf0RegPtr->ch0_lctrl_mode = lctrl_mode;
  35.     } else {
  36.         lConf0RegPtr->ch1_pos_mode = pos_mode;
  37.         lConf0RegPtr->ch1_neg_mode = neg_mode;
  38.         lConf0RegPtr->ch1_hctrl_mode = hctrl_mode;
  39.         lConf0RegPtr->ch1_lctrl_mode = lctrl_mode;
  40.     }
  41. }
with PCNT

ESP_Angus
Posts: 2178
Joined: Sun May 08, 2016 4:11 am

Re: compiler bug, occures in "hal/pcnt_ll.h" - Expresion regarded as CONST ?

Postby ESP_Angus » Mon Mar 02, 2020 12:14 am

Hi ESPI,

Thanks for reporting this. Is your project written in C++ or C?

I believe this isn't a compiler bug, it looks like this code is valid C but not valid C++ because of the type conversion - so currently you can't include this header into a .cpp file without getting errors like the above.

Will fix ASAP.

ESPI_1
Posts: 10
Joined: Thu Feb 27, 2020 7:08 am

Re: compiler bug, occures in "hal/pcnt_ll.h" - Expresion regarded as CONST ?

Postby ESPI_1 » Mon Mar 02, 2020 7:39 am

Hi ESP_Angus

the Header is included via "driver/pcnt.h" and "pcnt_hal.h" from an .CPP file

the other aproach could be to avoid this inline in this Header File
--> Code moves from Header into a .c File

Who is online

Users browsing this forum: No registered users and 4 guests