espsoftwareserial
espsoftwareserial copied to clipboard
add "weak" attribute to function isValidGPIO , isValidRxGPIO , isValidTxGPIO
This request is a followup of #240 (valid pins for RX/TX, strapping pins ...) Please could you add "weak" attribute to the functions:
bool isValidGPIOpin(int8_t pin);
bool isValidRxGPIOpin(int8_t pin);
bool isValidTxGPIOpin(int8_t pin);
bool isValidGPIOpin(int8_t pin) __attribute__ ((weak));
bool isValidRxGPIOpin(int8_t pin) __attribute__ ((weak));
bool isValidTxGPIOpin(int8_t pin) __attribute__ ((weak));
In this way the user can replace them and still use the standard library. No need for "patched" local version of the library. No compatibility issues. Regards
Is there any particular reason you prefer C-style weak linkage over C++ polymorphism?
Sorry, I am not a C++ expert (nor even a C one !) ... Just trying to play a bit with microcontrolers... I just found that it was very easy to use my own isValidGPIOpin if the function is declared with the weak attribute in the library. Just need to write my own function and the linker will gives it priority. I don't know how it can be done in the C++ polymorphism context.
Keeping #261, closing this one.