I’ve a question concerning configuration of libraries:
The related library files for my ESP32 projects are in one sub-directory “lib”, the parent directory is “ESP32Libraries” and included per lib_extra_dirs.
Compilation and linking works fine, what I’m missing is the following:
A “.h” file in the library may contain a preprocessor “#define” which configures some structure in this specific library, e.g. number of GPIO’s or ADC inputs.
In each projects “include” directory is a “config.h” file to configure this specific project.
How can I forward these definitions form this config file into the related header file of the library ?
The gola is simply to configure the libraries before compilation well knowing that this is not a real library, more collection of common files or functions.
An inclusion of the project file with an relative path didn’t work
e.g. #include “…/…/ESP32ProjectRoot/P1/include/config.h” in the lib header
and a dynamic allocation of ressources per constructor would require a complete redesign and to be honest I’don’t like this for microcontrollers, where only one instance of a certain class is needed.
Grateful for any hints and I hope the concept is understandable,
If you add
build_flags to your
platformio.ini and in that setting,
-include filename where filename is the required header you need, without quotes I believe.
That is the same as typing
#include "filename" in your main source file. With double quotes this time.
Other possible parameters and exalmples on this page: Redirecting....
That might work?
solution was to setup a dedicated “.h” file in the project include directory: e.g. defines.h
and set the build_flags: “build_flags=-include"pathtodefine.h”
the quotes are crucial and in the build flags line no white space ist allowed !