including standard library files to project

sparks
Posts: 8
Joined: Sun Oct 23, 2022 9:12 am

including standard library files to project

Postby sparks » Sun Oct 23, 2022 9:17 am

Hello!

I'm trying to include standard library files to my project, but getting errors with "Unresolved inclusion". These files also cannot be opened in editor with "Open declaration" context menu item:

Code: Select all

#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stddef.h>
How can I use these files, maybe I miss some REQUIRES options in my component?

Thank in advance!

IDE: Espressif-IDE
Version: 2.6.0
Build id: 20220811-0838

Target: esp32

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: including standard library files to project

Postby ESP_igrr » Sun Oct 23, 2022 9:47 am

Normally the standard library headers are available without any extra settings.
Do the errors only show up in the editor, or do they also occur when you try to build the project?
If the errors only occur in the editor, it might be an issue in the IDE.
If the errors also occur during the build, can you give more details about your project, like the contents of the CMakeLists.txt files?

RalphD
Posts: 103
Joined: Thu Nov 25, 2021 9:02 pm

Re: including standard library files to project

Postby RalphD » Sun Oct 23, 2022 10:30 am

I have exactly the same experience with 2.6
I have a project based on the https server example and set up a new computer with Eclipse 2022-06 idf plugin 2.6 and imported the existing project. All was fine except the compile did not go through because uart_config_t could not be resolved and NULL was undefined.

In further investigation I found that hal/uart_types.h was not included (file missing)

so this
Normally the standard library headers are available without any extra settings.
is a dream (or a lie)

I did try what not, nothing solved this issue. Remember my project compiled and ran fine before. I have to get my project running till tomorrow. I had the idea to make a new project with the HTTPS server example and copy my view source files over.

And now it comes, when I created the simple https sample project in the same workspace THE UNRESOLVED REFERENCES DISAPPEARED in my own project. After I could CTRL-click on hal/uart_types.h and it opened. uart_config_t and NULL was defined like before.

My project compiles and runs now (almost)fine. Just because I created a sample project in the same workspace.

Please find an explanation for this. This IDE is wasting thousands of man hours around the world for this sort of issues.

For somebody who will eventually work on a fix for this issue with the IDF it might be a good starting point why I can not just copy my projects into a new workspace or just check out from my Git repo, compile and run.

I think the issue for the above explained behavior should be found in the reason why I do have to IMPORT a project from another workspace rather then just copy it on OS level.

I am very frustrated with this dev environment, working with it now more then a year. Mainly spending my time sorting out exactly these type of issues.

May god be with you

Ralph

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: including standard library files to project

Postby ESP_igrr » Sun Oct 23, 2022 10:38 am

Hi Ralph,
RalphD wrote: In further investigation I found that hal/uart_types.h was not included (file missing)
The original question in this topic was about the C standard library headers.

hal/uart_types.h is not a standard library header, it is one of the headers provided by ESP-IDF "hal" component.

Could you please try to do the following to troubleshoot this issue:
1. Remove the project build directory
2. Build the project
3. Attach here the complete build log

This should give us enough information to diagnose the issue.

RalphD
Posts: 103
Joined: Thu Nov 25, 2021 9:02 pm

Re: including standard library files to project

Postby RalphD » Sun Oct 23, 2022 10:54 am

well I think we can agree that any include is found through he same mechanism, standard header or component header doesn't matter. The path must be set and known by the compiler.

deleting the build directory is standard procedure for anyone working in teams with this IDE.

the question remains, why do I have to IMPORT my custom projects rather then just copy them into the workspace. The cause must be the same issue.

RalphD
Posts: 103
Joined: Thu Nov 25, 2021 9:02 pm

Re: including standard library files to project

Postby RalphD » Sun Oct 23, 2022 10:59 am

and I forgot isn't NULL defined in stddefs.h ? I thought this is a standard include file.

sparks
Posts: 8
Joined: Sun Oct 23, 2022 9:12 am

Re: including standard library files to project

Postby sparks » Sun Oct 23, 2022 1:53 pm

ESP_igrr wrote:
Sun Oct 23, 2022 9:47 am
Normally the standard library headers are available without any extra settings.
Do the errors only show up in the editor, or do they also occur when you try to build the project?
If the errors only occur in the editor, it might be an issue in the IDE.
If the errors also occur during the build, can you give more details about your project, like the contents of the CMakeLists.txt files?
Thank you for the answer! Yes it looks like that the errors refer to IDE, because the project is built successfully. After creating new workspace and adding the same project the errors are gone and "Open declaration" and other IDE tools work just fine. Seems like Eclipse is really very buggy and problematic.

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: including standard library files to project

Postby ESP_igrr » Sun Oct 23, 2022 4:27 pm

RalphD wrote: standard header or component header doesn't matter. The path must be set and known by the compiler.
The difference between a standard header and a component header is that whether the latter is available is controlled by component dependencies in the build system. (If a component A doesn't add component B as a dependency, then B's headers wouldn't be available to A). In case of the standard headers, they are always available.
RalphD wrote: the question remains, why do I have to IMPORT my custom projects rather then just copy them into the workspace. The cause must be the same issue.
Could you please open a a bug report for this at https://github.com/espressif/idf-eclipse-plugin/issues? Someone working on the IDE will try to help with this issue.
sparks wrote: After creating new workspace and adding the same project the errors are gone and "Open declaration" and other IDE tools work just fine.
Thanks, it's an interesting detail! I found a similar looking issue at https://github.com/espressif/idf-eclips ... issues/587, could you please post this extra detail there?

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 117 guests