Search code examples
cmacrosc-preprocessorglibc

Undefine a function-like macro in C?


I am trying to do some hacks over the glibc, and I wanted to know whether it's possible to redefine function-like macros ?

For example, <tgmath.h> has the following macro:

#define expm1(Val) __TGMATH_UNARY_REAL_ONLY (Val, expm1)

How to redefine expm1 as :

#define expm1(Val) __TGMATH_UNARY_REAL_IMAG (Val, expm1, cexpm1)

I suppose that I have to cancel the previous definition but I do not know exactly how to do that.


Solution

  • Exactly. Just undefine it first.

    #ifdef expm1
    #undef expm1
    #endif
    
    #define expm1(Val) __TGMATH_UNARY_REAL_IMAG (Val, expm1, cexpm1)