Thank you for your answer.
I think I understand your solution but it is not what I'm trying to do.
I'm building a new package with my boards and my own core (based on samd Arduino core). Extending Adafruit_MCP-23008 class to differenciate between extended and normal pins is a good solution but it is not what I'm aiming for because this solution would imply the user to use an object of this sub-class. Then, the user must know that in order to use my board it has to create an object like this:
mySubclass myObject;
and then use it as follows:
myObject.digitalWrite(pin, status);
My idea is to hide those details from the user so he only needs to write:
digitalWrite(pin, status)
that is, the function used in all Arduino boards.
To summerize, I need digitalWrite(pin, status) to behave as I want in order to hide those details from the user.
The final user will see a name for the pin in the board and will write digitalWrite(pinName, status). He will not know anything about MCP23008 expansor and nothing about additional software requirements such as creating an object of the class MCP23008/MCP23008_subclass.
On the internet I found suggestions about making those functions weak:
__attribute __ (weak)
so they got overriden.
I also thought about changing the name for the Arduino defined functions as follows:
_digitalWrite(pin, status) (adding underscore)
and then define in a separete file written by me a function called:
digitalWrite(pin, status) (without underscore)
Would that do the trick and be a good practice?
Thank you very much for your time.