Posts

Showing posts with the label glibc

is it possible to overwrite strdup from with my own?

is it possible to overwrite strdup from <string.h> with my own? I need to do so because I am supposed to stub this function for unit testing. I am using gcc version 5.4.0. for a lot of other functions that exist in glibc like memcpy I simply wrote the implementation in my .c file and then this implementation was the one used instead of the original, but in case of strdup and some other function I get a compilation error like this one: error: expected identifier or ‘(’ before ‘__extension__’ char* strdup (const char *__s) I know this is because I am trying to use a function name that already exist in string.h although it works with some other functions in their as well. I wish to know if it is possible to bypass this somehow. Welcome to stackoverflow.com. Please take some time to read the help pages, especially the sections named "What topics can I ask about here?" and "What types of questions should I avoid asking?". Also please t...