Preprocessor token pasting in GCC’s _Pragma operator
After much trial and error, it turns out that the simplest solution works:
#ifdef _OPENMP
# define LIB_PRAGMA_OMP(x) DO_PRAGMA(omp x)
# define DO_PRAGMA(x) _Pragma ( #x )
#else
# define LIB_PRAGMA_OMP(x)
#endif
With -DOPENMP
, I get:
# 12 "test_op.cpp"
#pragma omp parallel
# 12 "test_op.cpp"
And without it, nothing.