#ifdef inside #define
I am trying to write something like this:
#define COV_ON(x) \
#ifdef COVERAGE_TOOL \
_Pragma (COVERAGE #x)
#endif
Is there any way to define COV_ON
like this? I know what I have done above is wrong as I can't have #ifdef
inside #define. (#
is not an allowed character in #define
).
So is there any solution?
Solution 1:
Not possible. Do it the other way around:
#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x)
#endif
Solution 2:
Simply turn it around:
#ifdef COVERAGE_TOOL
#define COV_ON(x) _Pragma (COVERAGE #x)
#else
#define COV_ON(x) /* foo */
#endif