Including h files from a directory above


I'd like to include a header file that I need for multiple projects. Since this file will be the same across all projects, I want to reduce redundancy and maintainability in case I need to change this file. Hence, I want to save the file in my projects folder and include it in the individual projects. My directory would look like this:

Arduino projects
- global_defines.h
- project 1
- project 2
- ...
- project n

In the files, I tried including the header file like this:

#include "../global_definitions.h"

This usually works in C++, but not in the Arduino environment.

Any tips would be appreciated.

the arduino sketch files are copied, at least on my laptop under


to a directory names arduino_build_xxxxx

the include is not copied because it is above your local sketch directory.

there may be a library directory you can specify

You simple create a subfolder under the folder libraries.

The naming-convention is that the name of the subfolder is exact the same as the library-name.

If they are the same you can include your special library the same way as "standard-libraries
#include <myLibrary.h>

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.