I’m generating many identical functions with small differences using C #defines. Inside these I use pragmas. This doesn’t work with old C #pragma directive, but should work using standard C99 _Pragma. The following example, for example, works with GCC:
#define MKFUN(X, OP) \
void X(double *dst, double *src, size_t n) \
{ \
_Pragma("omp parallel for") \
for(size_t i=0; i<n i++){ \
dst[i]=OP(src[i]); \
} \
}
MKFUN(multiexp, exp)
It fails with PGCC, which complains
PGC-S-0036-Syntax error: Recovery attempted by inserting ‘;’ before ‘{’
Looking at the output of the preprocessor (pgcc -E), it seems to replace _Pragma with #pragma during the preprocessing, which makes the compiler fail, because the whole expansion MKFUN(multiexp, exp) is on a single line.
I think is a bug in PGCC, not conforming to C99. In the meanwhile, does anyone know a simple workaround, which does not involve a custom preprocessor hack for function generation?