OS/2 codes: How to override standard functions in kLIBC
Sometimes there is a time when it is needed to override the functionality of some functions. To do this, at least two ways can be considered. Macros First is to use macros. For examples, if you want to override pipe(), then you can write the codes like this. Colored By Color Scripter ™ 1 2 3 4 5 6 7 8 9 10 #include <io.h> int my_pipe( int *ph) { some_codes; return (pipe)(ph); } #define pipe(ph) my_pipe(ph) At line 7, a parenthesis is used to prevent pipe() from being expaned to my_pipe() by a macro. This way has an advantage that this can be applied to all the functions. But this has a disadvantage that this can be applied only locally. If you want to apply globally, then you should create a header for a macro and all the sources should include that header. Alias The other way is to use alias. kLIBC provides aliases for standard functions, which do not have a leading underscore. Standard functions have at least two names.