I am trying to write something like this:
#define COV_ON(x) \\ #ifdef COVERAGE_TOOL \\ _Pragma (COVERAGE #x)
As you mentioned it is not possible to have an #ifdef in a #define. What you should do instead is reverse the order:
#ifdef COVERAGE_TOOL \ #define COV_ON(x) \ etc. #endif