How to structure includes?

Ok, I have several sketches, lets call them Sketch1, Sketch2, and Sketch3.

Each has some routines that are all identicle and I would like to remove them from the individual sketches and put them in a single common file. I want each of the 3 sketches include the single common file so that when routines are added to the common each of the main sketches has it.

I know bout putting multiple sketch files in the folder with the main sketch and it will add them in tabs. This requires a copy of the common in each folder. Not what I want. I want the sketches to draw from a single centralized copy.

How do I structure this and get it done?

create folder myinc inside libraries folder
copy the 3 routines into myinc.h file and save inside myinc folder.

#include <myinc.h>

abrookfield:
create folder myinc inside libraries folder
copy the 3 routines into myinc.h file and save inside myinc folder.

#include <myinc.h>

In a header file? Seriously? The code I want in there is standard arduino C straight from a sketch, not CPP files as would be used in a library.

The code I want in there is standard arduino C straight from a sketch, not CPP files as would be used in a library.

The difference being?

Common functions belong in a library, so they can be reused. You can use either the .c extension or the .cpp extension, but I can almost guarantee you that if you use the .c extension, you'll be back wanting to know why the library doesn't work.

Ok, will try it. I just didn't consider this common code a "library" in the strictest sense. It was really meant to only be common for a few scripts for a project I am working on. The code probably isn't very usable by other applications due to its nature.

The scripts are for logging data to an I2C eeprom, resetting the headers in the eeprom (resetting data pointers and start locations), and extracting the data as a CSV file. The common functions involve the recording format and the eeprom "file" header structure and defines for it. Thats why I never really considered it a library per se.

I created a mini-library for the read/write functions for the I2C EEPROM and I did convert that code to a library (.h and .cpp) in my libraries folder. I am also in the process of doing the same for the code for the I2C RTC module. I was going to share those two as I see them as being useful across many projects and might ease development by others. I just have to suss out the submisison procedure for the playground here.

I just didn't consider this common code a "library" in the strictest sense.

A library is just a way of writing a function once and using it in more than one project. That sounds like your situation.

Whether you share that library, or not, has no impact on whether it is a library, or not.

The common functions involve the recording format and the eeprom "file" header structure and defines for it.

They sound like candidates for reuse to me. Therefore, they belong in a library so they can be reused.

Don't think so narrowly about what a library is or is not.

PaulS:
Don't think so narrowly about what a library is or is not.

Point taken.