PlatformIO Community

How to get the values of the global project parameters **from the library**?

Sorry for the possibly stupid question.

How to get the values ​​of the global project parameters from the library?
The espidf framework has a great opportunity to configure the project using sdkconfig.h. This file will be available to any library included in the project. Sumptuously!

But if I try to build a project for the same ESP32, but already with the arduino framework, I will no longer be able to put “my” variables into it. There are no problems with the main project file - I can define constants in some file, for example project_config.h:
image
… and put it in the include or src directory. Problems start when I need this variable in a library that is linked to the project. She doesn’t know anything about project_config.h :frowning:
image

Of course, I can define these parameters in platformio.ini:
image
But this is not always convenient.
Firstly, there will be a lot of such parameters.
Secondly, the library can be used outside of platformio (in arduino for example).

Question: how can I organize the project structure so that the project_config.h file is accessible from the connected libraries, that is, some analogue of sdkconfig?

While my library is located locally, then I got out like this:

image

But this does not work when I connect the library via lib_deps and for ESP 8266.

Defining macros before linking the library does not work either. It works more precisely, but only if there is only one library. If there are several of them, then everything collapses

Please, tell me a way how to #include the project parameters file from the linked library?

Where is the project_config.h located within the project? In the include/ folder, right?

If it’s in the src/ folder you can try build_flags = -Isrc

I tried to put it wherever possible:

image

It is perfectly “visible” from main, and from the libs subfolder with the above perversions.
But from the folder where the libraries are downloaded from the repository - alas, no. How would you define the current project directory in #include?

Regarding docs have you tried the angle brackets form?

#include <project_config.h>

should pretty much work universally even without __has_include if the file is just in the include/ folder.

Alas, it didn’t work. I’m already desperate.

Adding to the platformio.ini

[env]
build_flags = -Isrc

Solved the problem. THANK YOU