Page 1 of 1

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

Posted: Thu Feb 27, 2020 8:16 am
by ESPI_1
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.





Code: Untitled.cpp Select all



#ifdef __cplusplus
extern "C"
{
#endif

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 */
}
};

void app_main(void)
{
...
i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, & cI2cConfig);

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

Posted: Thu Feb 27, 2020 9:16 am
by Sprite
Moved to the IDE subforum.

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

Posted: Fri Feb 28, 2020 6:24 am
by kondalkolipaka
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.

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

Posted: Fri Feb 28, 2020 7:06 am
by ESPI_1
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"

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

Posted: Fri Feb 28, 2020 9:01 am
by chegewara
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.

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

Posted: Fri Feb 28, 2020 1:32 pm
by ESPI_1
Still the same Problem when I moved the nested struct init outside the Extern "C"

Code: Untitled.cpp Select all



typedef enum{
I2C_MODE_SLAVE = 0, /*!< I2C slave mode */
I2C_MODE_MASTER, /*!< I2C master mode */
I2C_MODE_MAX,
} i2c_mode_t;

/**
* @brief I2C initialization parameters
*/
typedef struct{
i2c_mode_t mode; /*!< I2C mode */
int sda_io_num; /*!< GPIO number for I2C sda signal */
int scl_io_num; /*!< GPIO number for I2C scl signal */
bool sda_pullup_en; /*!< Internal GPIO pull mode for I2C sda signal*/
bool scl_pullup_en; /*!< Internal GPIO pull mode for I2C scl signal*/

union {
struct {
uint32_t clk_speed; /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
} master; /*!< I2C master config */
struct {
uint8_t addr_10bit_en; /*!< I2C 10bit address mode enable for slave mode */
uint16_t slave_addr; /*!< I2C address for slave mode */
} slave; /*!< I2C slave config */
};
} i2c_config_t;


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 when in main.cpp file: this Symbol could not be resolved */
}
};

void UseNestedStruct(void)
{
i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, &cI2cConfig);
ssd1306_handle_t lSsd1306_handle = iot_ssd1306_create(lI2cBusHandle, SSD1306_I2C_ADDRESS);
esp_err_t lEspErr;
lEspErr = iot_ssd1306_clear_screen(lSsd1306_handle, 0);
if(lEspErr){
//...
}
}


#ifdef __cplusplus
extern "C"
{
#endif

void app_main(void)
{

UseNestedStruct();
//old-code: i2c_bus_handle_t lI2cBusHandle = iot_i2c_bus_create(0, & cI2cConfig);

}

#ifdef __cplusplus
}
#endif