This pragma causes every externally defined occurrence of the name old_extname in the object code to be replaced by new_extname. As a result, the linker only sees the name new_extname at link time. If #pragma redefine_extname is encountered after the first use of old_extname, as a function definition, an initializer, or an expression, the effect is undefined. (This pragma is not supported in -Xs mode.)
When #pragma redefine_extname is available, the compiler provides a definition of the predefined macro PRAGMA_REDEFINE_EXTNAME which lets you write portable code that works both with and without #pragma redefine_extname.
The purpose of #pragma redefine_extname is to allow an efficient means of redefining a function interface when the name of the function cannot be changed. For example, when the original function definition must be maintained in a library, for compatibility with existing programs, along with a new definition of the same function for use by new programs. This can be accomplished by adding the new function definition to the library by a new name. Consequently, the header file that declares the function uses #pragma redefine_extname so that all of the uses of the function are linked with the new definition of that function.
#if defined(__STDC__) #ifdef __PRAGMA_REDEFINE_EXTNAME extern int myroutine(const long *, int *); #pragma redefine_extname myroutine __fixed_myroutine #else /* __PRAGMA_REDEFINE_EXTNAME */ static int myroutine(const long * arg1, int * arg2) { extern int __myroutine(const long *, int*); return (__myroutine(arg1, arg2)); } #endif /* __PRAGMA_REDEFINE_EXTNAME */ #else /* __STDC__ */ #ifdef __PRAGMA_REDEFINE_EXTNAME extern int myroutine(); #pragma redefine_extnmae myroutine __fixed_myroutine #else /* __PRAGMA_REDEFINE_EXTNAME */ static int myroutine(arg1, arg2) long *arg1; int *arg2; { extern int __fixed_myroutine(); return (__fixed_myroutine(arg1, arg2)); } #endif /* __PRAGMA_REDEFINE_EXTNAME */ #endif /* __STDC__ */