Eclipse showing source errors [was: Good way to initialize struct in C++]

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby brazoayeye » Wed May 06, 2020 5:49 pm

Hello,

i'm having troubles with C++ struct initialization and I whould like to have your opinion regarding most convenient way.

For example I can't write

Code: Select all

const httpd_uri_t uri_post = {
    .uri       = "/",
    .method    = HTTP_POST,
    .handler   = httpd_get_handler
};
with

Code: Select all

httpd_uri_t uri_post;
void uri_post_default() {
	uri_post.uri	= "/";
	uri_post.method	= HTTP_POST; // uri_post
	uri_post.handler	= httpd_get_handler;
}
and to call uri_post_default() during initialization. That's not handy, and I categorically exclude code where element are not called by name (hard to identify problems).

IntrepidUniverse
Posts: 5
Joined: Wed May 06, 2020 6:06 pm

Re: Good way to initialize struct in C++

Postby IntrepidUniverse » Wed May 06, 2020 7:10 pm

Hi Brazoayeye.

Your first code snippet compiles using the latest tools.

Can you post the error you are seeing?

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

Re: Good way to initialize struct in C++

Postby brazoayeye » Mon May 11, 2020 8:24 pm

You are right, if I compile i don't have the error.

I only have the error in eclipse:
Image link

Since building with eclipse works fine, is there a way to skip the error check in that line during the browsing?

The point regarding a way to initialize structs without a called function is still open.

Thanks

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

Re: Good way to initialize struct in C++

Postby ESP_Angus » Tue May 12, 2020 3:17 am

Hi brazoayeye,

It is possible for the Eclipse project to be configured incompletely, meaning that although the project can build it doesn't know everything necessary for the code editor to work properly. Suggest following the Eclipse setup instructions again see if you missed a step.

If that doesn't help, please answer the following questions and we can try to give more detailed advice:

Which version of ESP-IDF are you using?

What operating system are you building from?

What setup step(s) did you follow to configure Eclipse?

Are you using the new Eclipse plugin for CMake, or the older/simpler Eclipse integration with Eclipse + GNU Make build system?

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

Re: Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby brazoayeye » Tue May 12, 2020 6:09 am

I'm using the eclipse plugin, but I come from a nightmare of different test with a previous version (to compile a legacy code) for the idf 3.3. I remember I tried to follow the standard ecplise setup for the 3.3 idf version, but I had errors and then i compiled with mingw32.exe and edited with VSCode.

After that, I downloaded the latest idf and I tried to install the eclipse plugin, but I had errors.

Then I downloaded the Windows tool installer, and i moved to the native windows version, where I reached some results even if I needed to download again the IDF from scratch as described here: https://esp32.com/viewtopic.php?f=13&t=15572
The error was the same with 4.0 and 4.2, I will try to reset eclipse and install the plugin again, then I will update you.

Thanks

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

Re: Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby brazoayeye » Tue May 12, 2020 3:34 pm

I'm using

Code: Select all

C:\esp-idf>idf.py --version
ESP-IDF v4.2-dev-1415-ga2263571b
I removed ecplipse, I installed 2020-03 version for C/C++, i added the repo https://dl.espressif.com/dl/idf-eclipse ... es/latest/ and installed all the software.

Restarted eclipse

I made install tools configuring C:\esp-idf\ C:\python\python.exe and C:\Program Files\Git\git-cmd.exe , having this output
Installing tools...
This can take a while. Please be patient.
Executing C:\python\python.exe C:\esp-idf\tools\idf_tools.py install all
Installing tools: xtensa-esp32-elf, xtensa-esp32s2-elf, esp32ulp-elf, esp32s2ulp-elf, cmake, openocd-esp32, ninja, idf-exe, ccache
Skipping xtensa-esp32-elf@esp-2020r1-8.2.0 (already installed)
Skipping xtensa-esp32s2-elf@esp-2020r1-8.2.0 (already installed)
Skipping esp32ulp-elf@2.28.51-esp-20191205 (already installed)
Skipping esp32s2ulp-elf@2.28.51-esp-20191205 (already installed)
Skipping cmake@3.16.4 (already installed)
Skipping openocd-esp32@v0.10.0-esp32-20200420 (already installed)
Skipping ninja@1.10.0 (already installed)
Skipping idf-exe@1.0.1 (already installed)
Skipping ccache@3.7 (already installed)

Executing C:\python\python.exe C:\esp-idf\tools\idf_tools.py install-python-env
Processing c:\msys32\home\xxx\esp\esp-idf\tools\kconfig_new\esp-windows-curses
Requirement already satisfied: setuptools>=21 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 4)) (46.1.3)
Requirement already satisfied: click>=5.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 8)) (7.1.2)
Requirement already satisfied: pyserial>=3.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 9)) (3.4)
Requirement already satisfied: future>=0.15.2 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 10)) (0.18.2)
Requirement already satisfied: cryptography>=2.1.4 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 11)) (2.9.2)
Requirement already satisfied: pyparsing<2.4.0,>=2.0.3 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 12)) (2.3.1)
Requirement already satisfied: pyelftools>=0.22 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 13)) (0.26)
Requirement already satisfied: gdbgui>=0.13.2.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (0.13.2.0)
Requirement already satisfied: pygdbmi<=0.9.0.2 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from -r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 15)) (0.9.0.2)
Requirement already satisfied: windows-curses in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from esp-windows-curses==0.1->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 22)) (2.1.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from cryptography>=2.1.4->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 11)) (1.14.0)
Requirement already satisfied: six>=1.4.1 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from cryptography>=2.1.4->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 11)) (1.14.0)
Requirement already satisfied: Flask<1.0,>=0.12.2 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (0.12.5)
Requirement already satisfied: Pygments<3.0,>=2.2.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (2.6.1)
Requirement already satisfied: Flask-SocketIO<3.0,>=2.9 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (2.9.6)
Requirement already satisfied: gevent<2.0,>=1.2.2 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (1.5.0)
Requirement already satisfied: Flask-Compress<2.0,>=1.4.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (1.5.0)
Requirement already satisfied: pycparser in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from cffi!=1.11.3,>=1.8->cryptography>=2.1.4->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 11)) (2.20)
Requirement already satisfied: Werkzeug<1.0,>=0.7 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Flask<1.0,>=0.12.2->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (0.16.1)
Requirement already satisfied: Jinja2>=2.4 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Flask<1.0,>=0.12.2->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (2.11.2)
Requirement already satisfied: itsdangerous>=0.21 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Flask<1.0,>=0.12.2->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (1.1.0)
Requirement already satisfied: python-socketio>=1.6.1 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Flask-SocketIO<3.0,>=2.9->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (4.5.1)
Requirement already satisfied: greenlet>=0.4.14; platform_python_implementation == "CPython" in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from gevent<2.0,>=1.2.2->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (0.4.15)
Requirement already satisfied: brotli in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Flask-Compress<2.0,>=1.4.0->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (1.0.7)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from Jinja2>=2.4->Flask<1.0,>=0.12.2->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (1.1.1)
Requirement already satisfied: python-engineio>=3.9.0 in c:\users\xxx\.espressif\python_env\idf4.2_py3.6_env\lib\site-packages (from python-socketio>=1.6.1->Flask-SocketIO<3.0,>=2.9->gdbgui>=0.13.2.0->-r C:/msys32/home/xxx/esp/esp-idf\requirements.txt (line 14)) (3.12.1)
Building wheels for collected packages: esp-windows-curses
Building wheel for esp-windows-curses (setup.py): started
Building wheel for esp-windows-curses (setup.py): finished with status 'done'
Created wheel for esp-windows-curses: filename=esp_windows_curses-0.1-py3-none-any.whl size=1175 sha256=b4fdbe9c75a0763cfd756e7540b800d6a664314bfea9ec54359d0e12392f7c63
Stored in directory: c:\users\xxx\appdata\local\pip\cache\wheels\ff\08\d1\fa4e11107d5ac0d8f906cf6744df8be642e8aa5a38268eb92c
Successfully built esp-windows-curses
Installing collected packages: esp-windows-curses
Attempting uninstall: esp-windows-curses
Found existing installation: esp-windows-curses 0.1
Uninstalling esp-windows-curses-0.1:
Successfully uninstalled esp-windows-curses-0.1
Successfully installed esp-windows-curses-0.1
WARNING: You are using pip version 20.0.2; however, version 20.1 is available.
You should consider upgrading via the 'C:\Users\xxx\.espressif\python_env\idf4.2_py3.6_env\Scripts\python.exe -m pip install --upgrade pip' command.
Installing Python packages from C:/msys32/home/xxx/esp/esp-idf\requirements.txt

Executing C:\python\python.exe C:\esp-idf\tools\idf_tools.py export --format=key-value
OPENOCD_SCRIPTS=C:\Users\xxx\.espressif\tools\openocd-esp32\v0.10.0-esp32-20200420\openocd-esp32\share\openocd\scripts
IDF_CCACHE_ENABLE=1
IDF_PYTHON_ENV_PATH=C:\Users\xxx\.espressif\python_env\idf4.2_py3.6_env
PATH=C:\Users\xxx\.espressif\tools\xtensa-esp32-elf\esp-2020r1-8.2.0\xtensa-esp32-elf\bin;C:\Users\xxx\.espressif\tools\xtensa-esp32s2-elf\esp-2020r1-8.2.0\xtensa-esp32s2-elf\bin;C:\Users\xxx\.espressif\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin;C:\Users\xxx\.espressif\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin;C:\Users\xxx\.espressif\tools\cmake\3.16.4\bin;C:\Users\xxx\.espressif\tools\openocd-esp32\v0.10.0-esp32-20200420\openocd-esp32\bin;C:\Users\xxx\.espressif\tools\ninja\1.10.0\;C:\Users\xxx\.espressif\tools\idf-exe\1.0.1\;C:\Users\xxx\.espressif\tools\ccache\3.7\;C:\Users\xxx\.espressif\python_env\idf4.2_py3.6_env\Scripts;C:\msys32\home\xxx\esp\esp-idf\tools;%PATH%
Note that a lot of path points to the previous installed version: C:/msys32/home/xxx/esp/esp-idf\

The problem is always the same...

Thanks

IntrepidUniverse
Posts: 5
Joined: Wed May 06, 2020 6:06 pm

Re: Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby IntrepidUniverse » Wed May 13, 2020 7:51 am

It is difficult to keep multiple environments on the same machine. Here are some ways that can work:

1. Use a batch script to create a minimal environment - the idea is to remove references to msys etc so for example set PATH=C:\WINDOWS\system32. Then as you perform each step of the install only add to the PATH things you need. Then you can run eclipse with that environment and it should work.

2. Create a new user on the machine - the idea is that it will have a cleaner environment for the install. Note this will not work so well if you have system wide environment variable settings that are interfering as you will still pick those up. You can also have problems with file permissions if you do this and share files with the original user.

3. Use a Virtual Machine - for example do a small install of Linux and do all your work from that machine with a drive mapped to your source files so you can use them from both the guest and main host.

4. Build a Docker container - this will follow similar steps to 1 but at the end you will have a reproducible environment that you could also move easily to another machine.

brazoayeye
Posts: 41
Joined: Sun May 03, 2020 2:37 pm

Re: Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby brazoayeye » Wed May 13, 2020 5:05 pm

I don't need the old version anymore

I removed c:\msys32, removed its path, removed esp-idf path, removed eclipse pluign, installed the plugin again, Installed tool.

At first the problem seemed gone, but after first build it started again.

Is there something else i should try to have it running in the current OS without the error? (not virtualized)

Thanks

IntrepidUniverse
Posts: 5
Joined: Wed May 06, 2020 6:06 pm

Re: Eclipse showing source errors [was: Good way to initialize struct in C++]

Postby IntrepidUniverse » Wed May 13, 2020 6:54 pm

If you take a look at this video around 24:15 :
https://youtu.be/DqnZy4d03_s?t=1455

it suggests when you install the IDF from inside Eclipse it will set the toolchain and environment correctly. It shows where you can check those settings. Before a compile it shows errors similar to yours, the presenter checks the toolchain then builds and the errors go away.

So try and install the IDF from inside Eclipse (if you are not already doing it that way). Then create a new template project e.g. the hello_world project (the example 'blink' is shown in the video) and see if that compiles and shows no problems. If it works then compare your existing project settings and toolchain with the working example, or copy your source into the working project and see if it works then.

Who is online

Users browsing this forum: No registered users and 157 guests