I am trying to write something like this:
#define COV_ON(x) \\ #ifdef COVERAGE_TOOL \\ _Pragma (COVERAGE #x)
You cannot. But you can swap #ifdef and #define:
#ifdef
#define
#ifdef COVERAGE_TOOL # define COV_ON(x) _Pragma (COVERAGE #x) #else # define COV_ON(x) #endif