an example that not compile... with as less code possible to illustrate.
.ino
/////Ethernet W5100
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
//#include <EthernetClient.h>
//#include <EthernetServer.h>
////Ethernet2 W5500
/*
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet2.h>
//#include <EthernetClient.h>
//#include <EthernetServer.h>
*/
#include <testlib.h>
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
testlib.h
#ifndef TESTLIB
#define TESTLIB
#ifdef W5100_H_INCLUDED
#include "Ethernet.h"
#pragma message ( "W5100 network" )
#elif defined W5500_H_INCLUDED
#include "Ethernet2.h"
#pragma message ( "W5100 network" )
else
#pragma message ( "no network" )
#error "No or invalid network selected"
#endif
#include "Arduino.h"
class Testlib {
Testlib();
};
#endif
.cpp
#include "testlib.h"
Testlib::Testlib(){}
But I think it do not work because the only define variable different on the 2 lib is on the util folder in the w5100 and w550.h file that are deeper #included into the lib... maybe I should try to make a define inside each ethernet.h file to see what I got...