I have some virtual functions that I will never call that I'd like to get rid of. Since they are in the vtable, they are 'used' as far as the linker is concerned, so they stay in.
I tried creating an override class, and using stub implementations, but the originals are still there. I think that during object creation, the base class vtable is filled in then immediately over-written with the derived class, so it's still 'referenced'.
I'd rather not have to edit the base class (EthernetClient), since I don't control it
I'm using the EthernetClient class to receive connections. I'll never call 'connect()', and right now that's bringing in about 3000 bytes of dead code (mostly DNS name resolution), that's almost 10% of the available space on a UNO.
class WebEthernetClient : public EthernetClient
{
public:
EthernetClient& operator=(const EthernetClient& rhs);
private:
// Override function we don't use
virtual int connect(const char* host, uint16_t port) override;
};
int WebEthernetClient::connect(
const char*, uint16_t)
{
return 0;
}
EthernetClient& WebEthernetClient::operator=(const EthernetClient& rhs)
{
return EthernetClient::operator=(rhs);
}
Looking at the code map, all the DNS and UDP functionality is still being pulled in.
[Edit] Of course another problem is that other parts of the Ethernet library do instantiate the EthernetClient class, so it's probably an exercise in futility for this particular case.