Page 1 of 1

VS: editor disagrees with build results

Posted: Mon Nov 15, 2021 12:45 am
by mzimmers
Hi all -

I'm trying to clean up some minor issues with my use of the IDE. Currently, the editor detects errors that don't show up in the build. Hopefully this picture is a good representation:
editor.PNG
editor.PNG (72.84 KiB) Viewed 18757 times
I'm guessing that the editor is finding its way to an incorrect header file when there are multiple instances (for example, socket.h or lwipopts.h), but I'm not sure what to do about this. Do I need to refine the includePath definition in my c_cpp_properties.json file? Currently I'm just using a wildcard:

Code: Select all

                "${config:idf.espIdfPathWin}/components/**",
Thanks for any explanation of this.

Re: VS: editor disagrees with build results

Posted: Tue Nov 16, 2021 9:32 am
by ESP_bignacio
You could try to use the compile_commands.json from the build folder instead like:

https://github.com/espressif/vscode-esp ... URATION.md

Otherwise I think is about fine tuning the locations of

Code: Select all

"${config:idf.espIdfPathWin}/components/**"
to specific components you are using in your project. This syntax highlight is achieved by the Microsoft C/C++ extension and things like include and browser need to be manually tuned until we have a better automatic solution for it.

Re: VS: editor disagrees with build results

Posted: Tue Nov 16, 2021 9:32 pm
by mzimmers
Hi bignacio -

This is probably a good solution, though I'm still working out the kinks in my configuration. Two problems currently:

1. the editor claims it can't find the file specified by "compileCommands": "${workspaceFolder}/build/compile_commands.json"
2. when I add a header file (in this case, esp_ota_ops.h), it comes up as not found.

Re: VS: editor disagrees with build results

Posted: Wed Nov 17, 2021 9:57 pm
by mzimmers
BTT

I get this error whether using the IDE or not. Any suggestions?

Thanks...

Re: VS: editor disagrees with build results

Posted: Wed Nov 24, 2021 6:20 pm
by mzimmers
I've reverted to bignacio's suggestion of putting specific paths into the include section of my c_cpp_properties.json file, like this:

Code: Select all

            "includePath": [
                "${config:idf.espIdfPath}/components/lwip/lwip/src/include/lwip",
                "${config:idf.espIdfPath}/components/**",
                "${config:idf.espIdfPathWin}/components/**",
                "${config:idf.espIdfPath}/components/spi_flash/include",
                "${config:idf.espIdfPath}/components/bootloader_support/include",
                "${config:idf.espIdfPath}/components/hal/include/hal",
                etc.
This has solved all the problems I was having, except for the ones involving LwIP. For some reason, this line of code:

Code: Select all

#include "sockets.h"
Results in a compile error "no such file." I do notice that the path to this file doesn't appear in my build command as shown in the terminal, despite the presence of the line pointing to it in my c_cpp_properties.json file.

Can someone give me an idea of what's going on here?

Thanks...

Re: VS: editor disagrees with build results

Posted: Thu Nov 25, 2021 1:12 am
by boarchuz
Again, your Intellisense configuration is separate from your CMake configuration. You will never fix a compilation error by tweaking your Intellisense paths.

Make sure the component REQUIRES/PRIV_REQUIRES lwip in its CMakeLists.txt and then

Code: Select all

#include "lwip/sockets.h"

Re: VS: editor disagrees with build results

Posted: Thu Nov 25, 2021 5:28 pm
by mzimmers
Hi boarchuz -

My CMakeLists.txt file:

Code: Select all

idf_component_register( 
...
REQUIRES app_update bootloader_support driver esp_event esp_http_server esp_wifi freertos hal lwip nvs_flash spi_flash
)
And in a source file:
undefined.PNG
undefined.PNG (24.78 KiB) Viewed 18065 times
The squiggles indicate that the symbol is undefined. The project does build, however, so this is just a problem with my configuration (I think).

Thanks...