Just declare the struct in the header (defines.h):
struct data_t
{
char length;
char message;
};
This is only a declaration of a type, not a definition of a variable, so it can be in the header (i.e., it can be included multiple times without causing a "multiple definition" link error).
And you no longer need the typedef for struct types. They are really like a class now.
I didn't explain the full picture, I am trying to port a fairly large library which was originally written in C. It would be nice if I didn't have to edit the source code.
-dev:
Your library is wrong. You have to declare the struct in the header file.
And porting always requires editing.
You don't have to declare a struct in a header file. Some libraries "hide" structure definitions behind opaque pointers, but that means the user's code cannot access any struct members (which is the point of doing this). Take C's FILE structure, for example. User code passes around pointers to FILE, but it doesn't access its member fields directly.
joextodd: if you want to hide your struct definition (as in the original code), you can't access data->message from sketch.ino because sketch.ino doesn't know what the struct looks like.
-dev:
Um... he is accessing the struct member. This is not an opaque type.
Of course. I was pointing out the purpose of using an opaque pointer (which the library is using). I also pointed out that he cannot access struct members as he was doing in sketch.ino with the library as it is.