PeterH:
kaor:
During processing header2.h #include directive, does the preprocessor have HEADER1 definition?Yes, when it is included via header1.h, which is the case you're asking about.
(No, when header2.h is included separately and header1.h has not already been included in the compilation unit.)
The first problem is that you can't include in arduino library another library without including it directly to the ino file. If you try this, compiler gives error that object isn't defined (that is in another library, included in first)
.ino:
#include <lib1.h>
...
lib2 t;
lib1.h:
#include <lib2.h>
...
That is just ino file behavior as I understand, avr libraries for example can refer another libraries.
Also library can refer to classes inside the library folder, there are also may be src and utility folder that I am not understand quite clearly.
If I can include one library into another without including it the ino file, I'd go this way
server.ino:
#include <myserver.h>
mycommonclass c;
...
myserver.h:
#define DEVICETYPE 1
#include <mycommonclass.h>
mycommonclass.h:
#if DEVICETYPE=1
-server code here-
#endif
#if DEVICETYPE=2
-client code here-
#endif
and another ino
#include <myclient.h>