I'm finally getting back into Arduino after a bit of a vacation and a reinstallation, and have ran into an old issue from before my hiatus.
I'm trying to modularize my code by moving things into libraries, so I can avoid re-inventing the wheel or copy-pasting from one sketch to another to do things that need to be done frequently. (besides inconvenient, it means if I bugfix/update some code, I want it to immediately be updated everywhere I've used it, and with copy-paste, that's a nightmare, as well as being very unreliable) I made a Semaphore library that's working great. I also made a generic input debouncing library that's also working great. But I can't use the debouncing library IN a sketchbecause I can't get the debouncing library to include the semaphore library. (for key buffering)
After considerable googling around, I seem to have encountered a known issue with the linker in Arduino, that it fails to properly recognize #include statements in user libraries, (they can only include from the bundled libraries?) and I can't simply #include <Semaphore.h>
I also saw and tried #include "Semaphore.h", which seems to work for other built-in libraries, but not mine. (what's the difference?) The error I was getting was that the one Semaphore object defined in the header was an unknown type. That was the only error, and it was aborting the compile very early.
Others have suggested entering full paths to headers, or backing up. So I tried #include <../Semaphore/Semaphore.h>. That appeared to work, the compile proceeded and got very late in the process, I assume to the linker. And then it dumped out a bunch of new errors, every attempt to use a Semaphore::ClassFunction were showing up as undefined. It saw the class, but not its functions. Very annoying.
After much angst and trial and error, I finally resigned to find Arduino's primary library, and moved Semaphore.h/cpp into there, and change my include back to just plain #include <Semaphore.h>. And IT COMPILED 100%.
Please someone tell me there's some way to get user libraries to use other user libraries other than moving them in with the bundled ones? (the magic folder is Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/, for anyone that cares) For right now I'm keeping my library in the user library folder, and have dropped symlinks into the bundled library folder, for the sake of sanity and some thinly-veiled illusion of standardization. I know enough C to be dangerous, but have a lot of holes, and I'm praying that I'm simply missing a bit of syntax in my header file for my Semaphore that may mitigate this problem, if it can't be solved directly.
FWIW I have found one other work-around that is also a bit less than satisfactory. I moved the Semaphore.h/cpp into the same folder as the Debouncer library, and changed my include back to #include <Semaphore.h> and that compiles. (I did remove symlinks and relaunch IDE before testing) So I suppose that's slightly better than dropping library files into the compiler bundle, but can we do better? Id like to solve this as "by the book" as possible, with an edit to my libraries only and no filesystem shenanegans.