A few years ago you made recommendations for using #include with a header file of one's own. I have common code, actually just definitions #define or const that are common and I'd like to use only one header file. I followed the instructions Forum but it did not work.
This is what I've tried:
#include "Macintosh HD/Users/CarlosGLeon/Documents/Arduino/libraries/CGLlib/xx.h"
But I get the error: No such file or directory.
I’m not very knowledgeable about macOS, but that doesn’t look like an absolute path to me. You would need to use absolute paths for this approach, like what you would see in the terminal if you ran the pwd command.
But if “Macintosh HD/Users/CarlosGLeon/Documents/Arduino” is your sketchbook folder (as shown in the Arduino IDE’s File > Preferences > Sketchbook location field) then there is no need to specify the path to the header file at all:
You probably miss a leading / in your path (and the space in the path name might also be an issue, never tried). Try
#include "/Macintosh HD/Users/CarlosGLeon/Documents/Arduino/libraries/CGLlib/xx.h"
But if what @Pert suggested does not work, try with
I recommend placing the header file in the same folder as your sketch. See how to use header file
Thanks guys! Appreciate the help! Just tried using the same path as in IDE Preferences | Sketchbook location path (/Users/CarlosGLeon/Documents/Arduino) and just added "/CGLlib/xx.h" and it worked. So "/Users/CarlosGLeon/Documents/Arduino/CGLlib/xx.h" worked!
Then just "CGLlib/xx.h" should work too
Only with the original path under the libraries folder, the last post changed the path to be directly under the sketchbook folder for some reason.
And it would be #include <xx.h>, just like with any other library.
Right I misread the path. It’s not the sketch folder but just a generic repository of all personal sketches
@pert - I never tried this - Does the IDE look for specific .h in subfolders of the sketch ?