I would use a macro. It is more common and more idiomatic and faces fewer problems crossing translation units (i.e. you don't have to worry about declaring a macrostat).
In addition, by using a function pointer, you prevent most compilers from being embedded.
Finally, using a function pointer is possible for clients:
int evil(const int bgr) { } bgr2rgb = evil
Of course, they probably do not want this, but it is possible that there may be a variable in the string with a name similar to bgr2rgb , where only one typo is required ....
A macro is safer, although I would define it this way - there is no need for a functionally similar macro:
#define bgr2rgb rgb2bgr
Billy oneal
source share