I'm porting some code to Unix, and the library/OS that the original code is running on has some function calls named the same as std unix/posix system calls. For example both systems have a getpid(); call.
I'm writing a conversion library, and I need to figure out a way to override the uni/stdlib functions and then call them...
I was thinking of using a wrapper - i have the getpid() function in the library which then calls another function in another file say getpidUnix(). The getpidUnix() function then calls the Unix version of getpid() and returns the result. The file with the getpidUnix() function has the correct header files (in this case unistd.h). The issue clearly with this method is that getpidUnix() calls getpid() which is then linked to the other getpid().c file rather than the std unix library. This basically gives an infinite loop until the program crashes...
Is there any way I can easily do this without having to somehow use a make file to get the linker to look in the std lib before object files in the project directory?
Or is there a directive that I can use to get the compiler to ignore the local object files and look in the lib directory?
I have a few others that take different params for example calls to putc, printf etc... Func name is the same, but usage is different... I want to keep he usage consistent in the original source and make a conversion lib...
Any help is greatly appreciated!