Dear ESP32 forum members,
I am writing to seek your help regarding an issue I am facing while creating my lib to organize my project. I have been trying to find helpful sources to learn how to manage my files and related functionalities, but unfortunately, I have not been successful.
I am currently working on a webserver project, and I want to have files that hold related functionality for the web server. However, I am encountering an "unknown, undeclared error" which I am unable to resolve.
I have attached my error logs for your reference and would appreciate it if you could help me solve this problem. Additionally, I have shared the main code that I am using and my codes and multi-files for your review.
Main code: https://esp32tutorials.com/esp32-web-server-esp-idf/
My codes and multi-files: https://github.com/as-moh-nok/MeshNetwork_webserver
Thank you in advance for your assistance.
create multi files
create multi files
- Attachments
-
- My error
- unnamed.png (55.46 KiB) Viewed 973 times
-
- Posts: 1707
- Joined: Mon Oct 17, 2022 7:38 pm
- Location: Europe, Germany
Re: create multi files
To be able to use types and functions from other source files or libraries, your .c file needs to #include the respective header files; it can also do so indirectly:
Add #include "webServer.h" in your webServer.c
This way, everything #included in webServer.h is also included (and visible) in webServer.c.
To keep things more orderly, *.h files should only #include what's neccessary for the .h file to be used; the .c file should then #include whatever else it needs. For example, because your webServer.h does not reference any types from "driver/gpio.h", the #include "driver/gpio.h" is not needed in webServer.h and should be moved to webServer.c where it is actually needed.
Add #include "webServer.h" in your webServer.c
This way, everything #included in webServer.h is also included (and visible) in webServer.c.
To keep things more orderly, *.h files should only #include what's neccessary for the .h file to be used; the .c file should then #include whatever else it needs. For example, because your webServer.h does not reference any types from "driver/gpio.h", the #include "driver/gpio.h" is not needed in webServer.h and should be moved to webServer.c where it is actually needed.
Re: create multi files
Thank you, It is helpfull. But I recognize, the main problem is that I don't create good interface for my lib.MicroController wrote: ↑Mon Aug 14, 2023 2:11 pmTo be able to use types and functions from other source files or libraries, your .c file needs to #include the respective header files; it can also do so indirectly:
Add #include "webServer.h" in your webServer.c
This way, everything #included in webServer.h is also included (and visible) in webServer.c.
To keep things more orderly, *.h files should only #include what's neccessary for the .h file to be used; the .c file should then #include whatever else it needs. For example, because your webServer.h does not reference any types from "driver/gpio.h", the #include "driver/gpio.h" is not needed in webServer.h and should be moved to webServer.c where it is actually needed.
Who is online
Users browsing this forum: No registered users and 126 guests