VS: editor disagrees with build results

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

VS: editor disagrees with build results

Postby mzimmers » Mon Nov 15, 2021 12:45 am

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 18858 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.

ESP_bignacio
Posts: 229
Joined: Wed May 02, 2018 12:12 pm

Re: VS: editor disagrees with build results

Postby ESP_bignacio » Tue Nov 16, 2021 9:32 am

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.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: VS: editor disagrees with build results

Postby mzimmers » Tue Nov 16, 2021 9:32 pm

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.

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: VS: editor disagrees with build results

Postby mzimmers » Wed Nov 17, 2021 9:57 pm

BTT

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

Thanks...

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: VS: editor disagrees with build results

Postby mzimmers » Wed Nov 24, 2021 6:20 pm

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...

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: VS: editor disagrees with build results

Postby boarchuz » Thu Nov 25, 2021 1:12 am

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"

User avatar
mzimmers
Posts: 643
Joined: Wed Mar 07, 2018 11:54 pm
Location: USA

Re: VS: editor disagrees with build results

Postby mzimmers » Thu Nov 25, 2021 5:28 pm

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 18166 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...

Who is online

Users browsing this forum: No registered users and 47 guests