PlatformIO Community

Why .h files in src not found?

I have a simple project and am having crazy issues with header files.
I place a few header files in the project src folder. Some are found at compile time, others are not.
c_cpp_properties.json includes the following, so the src folder IS in the path.
“name”: “PlatformIO”,
“includePath”: [
“C:/Users/peted/OneDrive/Documents/PlatformIO/Projects/TDS June 4/include”,
“C:/Users/peted/OneDrive/Documents/PlatformIO/Projects/TDS June 4/src”
When I move the unfound .h file to lib/Config1/src/Config1.h, it is found. Why this difference when other .h files are found in the project src folder? (other .h files, such as myTemperature.h, in the project src folder work fine). There is no indication of a problem with Config1.h until I do the compile and then I get a file could not be opened error if it is in the project src folder. I have rebuilt the intellisense index and done cleans, wiped VS and platformio off my system and reinstalled, rebooted etc, etc but keep having this silly problem. Ideas?

That’s weird, usually it should not work at all that you have access to a project’s include files in src/ in a library folder (lib/xyz). A library is supposed to be self-contained code, only needing itself and other referenced libraries, but not files from the project itself.

Usually this is fixed by adding

build_flags = -Isrc

(assuming the header file that is not found is in src/) in the platformio.ini (docs), that is, making it a global compile option to add src to the include search path.

Thanks Max. That option did in fact fix the problem.
What I like to do is to divide my code up into fairly small files that have distinct functionality so, for example, I could change from an oled to and lcd display without having to look any further that the .c and .h files I associate with the display output. In this case, I was just adding a .h file to hold my pin assignments, again, so I have only one place to look to make changes. I normally put such a file (config.h) in my project src folder. Is this not a logical way to do things? (And it has worked on dozens of projects until this week for some reason, and then only for some files and not others…