Including "global" Header File to private Libraries


#1

I have written some private libraries (each has one .h and one .cpp file) , and placed them in the lib folder, in the way it is suggested in the README. So far everything works fine, i can include all the headers without compiling errors.

Now, the tricky part: in each of this libraries i need to access to variables specified in another (global) config.h, in which i have specified for example the used Pins of my chip. When i include this config.h (that is also placed in the lib folder) in the libraries, i can’t use the defined values, although I have included the config.h file…

WHY?! and how to get around this?? I simply get the error that the variables are not defined in this scope…

I have no idea what the problem is here, and would be thankful for some help!


#2

Please upload a minimal example to demonstrate the error.


#3

i can’t upload the folder structure here, but i have copied a sample project to Dropbox


#4

I found a solution: It seems like the name “config” is the problem. as soon I rename config.h to any other name, everything works as expected…


#5

That’s interesting. I think I have the same problem in one of my other projects…


#6

Did renaming solved the problem for you too? I opened a bug report on https://github.com/platformio/platformio-core/issues/1914


#7

I reconfigured that project to get around using a config.h using defs in the platform.ini defs. I was scratching my head over this one for some time. I just never mad the connection you did.

I will create a new project later to confirm.


#8

I also just found the “solution” , because i was creating a sample project for the bug report, (with names lib1 and lib2) and suddenly everything worked fine :rofl: