Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

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

Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby ESPI_1 » Thu Feb 27, 2020 8:16 am

Initialisation of nested struct (Example below)
1) C: works well (placed in a C-file "main.c"),
2) C++: Fails with Problem/ Errors (placed in a CPP-file: "main.cpp" - Simply the renamed "main.c"):

using ESP-IDS Eclipse Plugin v1.0.0-beta4:
reportes Problem: "Symbol 'clk_speed' could not be resolved"



when I press "Compile" or "Lanch" within the Eclipse-IDE,
the terminal-window reports: "Build-Complete (0 Errors, 3 warning) …. -->the toolchain accepts the nested struct initialisation

but from Eclipse, I get an error-message-box:
"Errors in Workspace"/"Error exist in required Project"

Pressing "Proceed" in this error-message-box- everythin is OK,
- Programm works, and has accepted the nested struct initialisation -
- I2C runs
- a c++ test-class also runs well


Seems, that somehow the Eclipse "syntax-checker"? has switched ist behaviour when renaming the file from "main.c" to "main.cpp".

Any Ideas, how to fix it?
- the Phantom-Errors are disturbing,
- the Eclipse-Problem-list is populated with them.





  1.  
  2. #ifdef __cplusplus
  3. extern "C"
  4. {
  5. #endif
  6.  
  7. static const i2c_config_t cI2cConfig = {
  8.         .mode       = I2C_MODE_MASTER,
  9.         .sda_io_num = 21,
  10.         .scl_io_num = 22,
  11.         .sda_pullup_en = true,
  12.         .scl_pullup_en = true,
  13.         .master = {
  14.                 .clk_speed = 100000 /* PROBLEM: Symbol 'clk_speed' could not be resolved when in .cpp file*/
  15.                                                         /* <-> works well when placed  .c file */
  16.                                                         /*  when simply ignoring the Problem-message - the toolchain produces correct output */
  17.                                                         /* seems a Eclipse configuration Problem */
  18.             }
  19. };
  20.  
  21. void app_main(void)
  22. {
  23. ...
  24.     i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, & cI2cConfig);

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby ESP_Sprite » Thu Feb 27, 2020 9:16 am

Moved to the IDE subforum.

ESP_kondalkolipaka
Posts: 188
Joined: Wed Jul 17, 2019 5:26 pm

Re: Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby ESP_kondalkolipaka » Fri Feb 28, 2020 6:24 am

Hello, Could you get the latest version of the eclipse plugin and try it. We have fixed a couple of issues related to "unresolve inclusion" errors in our previous releases.

https://github.com/espressif/idf-eclips ... v1.0.0-rc1

Thanks.

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

Re: Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby ESPI_1 » Fri Feb 28, 2020 7:06 am

Thank for Your fast Reply

but the Problem is still there.

Can you copy the Code and test it in a .cpp file?


My STEPS
1) I Unistall the ESP-IDF Eclipse Plugin v1.0.0-beta4 in the market-place
+ Restart eclipe

2) In Eclipse-Help-InstallSoftware
I added espressif ide - https://dl.espressif.com/dl/idf-eclipse ... es/latest/
Checked all items, accept everything
+ Restart eclipse

now,
I Can see in the list of installed Software
- Espressif IDF Plugins for Eclipse 1.0.0.202002201116 com.espressif.idf.feature.feature.group ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD

ESP-IDF Eclipse Plugin v1.0.0-beta4 in is back again in the eclipse market-place as "Installed"

chegewara
Posts: 2375
Joined: Wed Jun 14, 2017 9:00 pm

Re: Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby chegewara » Fri Feb 28, 2020 9:01 am

I think its not issue with plugin, more like C vs C++ intialization. Try to move this outside extern "C" guard:

Code: Select all

static const i2c_config_t cI2cConfig = {
        .mode       = I2C_MODE_MASTER,
        .sda_io_num = 21,
        .scl_io_num = 22,
        .sda_pullup_en = true,
        .scl_pullup_en = true,
        .master = {
                .clk_speed = 100000 /* PROBLEM: Symbol 'clk_speed' could not be resolved when in .cpp file*/
                                                        /* <-> works well when placed  .c file */
                                                        /*  when simply ignoring the Problem-message - the toolchain produces correct output */
                                                        /* seems a Eclipse configuration Problem */
            }
};
Probably it wont help, but who knows.

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

Re: Eclipse plugin, c++, symbol not resolved within Initialisation of nested struct

Postby ESPI_1 » Fri Feb 28, 2020 1:32 pm

Still the same Problem when I moved the nested struct init outside the Extern "C"
  1.  
  2. typedef enum{
  3.     I2C_MODE_SLAVE = 0,   /*!< I2C slave mode */
  4.     I2C_MODE_MASTER,      /*!< I2C master mode */
  5.     I2C_MODE_MAX,
  6. } i2c_mode_t;
  7.  
  8. /**
  9.  * @brief I2C initialization parameters
  10.  */
  11. typedef struct{
  12.     i2c_mode_t mode;     /*!< I2C mode */
  13.     int sda_io_num;      /*!< GPIO number for I2C sda signal */
  14.     int scl_io_num;      /*!< GPIO number for I2C scl signal */
  15.     bool sda_pullup_en;  /*!< Internal GPIO pull mode for I2C sda signal*/
  16.     bool scl_pullup_en;  /*!< Internal GPIO pull mode for I2C scl signal*/
  17.  
  18.     union {
  19.         struct {
  20.             uint32_t clk_speed;     /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
  21.         } master;                   /*!< I2C master config */
  22.         struct {
  23.             uint8_t addr_10bit_en;  /*!< I2C 10bit address mode enable for slave mode */
  24.             uint16_t slave_addr;    /*!< I2C address for slave mode */
  25.         } slave;                    /*!< I2C slave config */
  26.     };
  27. } i2c_config_t;
  28.  
  29.  
  30. static const i2c_config_t cI2cConfig = {
  31.         .mode       = I2C_MODE_MASTER,
  32.         .sda_io_num = 21,
  33.         .scl_io_num = 22,
  34.         .sda_pullup_en = true,
  35.         .scl_pullup_en = true,
  36.         .master = {
  37.                 .clk_speed = 100000 /* PROBLEM when in main.cpp file: this Symbol could not be resolved  */
  38.             }
  39. };
  40.  
  41. void UseNestedStruct(void)
  42. {
  43.     i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, &cI2cConfig);
  44.     ssd1306_handle_t lSsd1306_handle = iot_ssd1306_create(lI2cBusHandle, SSD1306_I2C_ADDRESS);
  45.     esp_err_t lEspErr;
  46.     lEspErr = iot_ssd1306_clear_screen(lSsd1306_handle, 0);
  47.     if(lEspErr){
  48.         //...
  49.     }
  50. }
  51.  
  52.  
  53. #ifdef __cplusplus
  54. extern "C"
  55. {
  56. #endif
  57.  
  58. void app_main(void)
  59. {
  60.     UseNestedStruct();
  61.     //old-code:   i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, & cI2cConfig);
  62. }
  63.  
  64. #ifdef __cplusplus
  65. }
  66. #endif

Who is online

Users browsing this forum: No registered users and 69 guests