Possible Duplicates:
C/C++ pragma in define macro
Conditional “pragma omp”
如何在宏定义中使用 OpenMP 编译指示?例如
#define A() { \
...a lot of code... \
#pragma omp for \
for(..) \
..do_for.. \
...another a lot of code \
}
最佳答案
正如这里的回答Conditional "pragma omp"
C99 has the
_Pragma
keyword that allows you to place what otherwise would be#pragma
inside macros. Something like
#define OMP_PARA_INTERNAL _Pragma("omp parallel for")
所以,
#define OMP_PARA_FOR _Pragma("omp for")
#define A() { \
...a lot of code... \
OMP_PARA_FOR \
for(..) \
..do_for.. \
...another a lot of code \
}
多个_Pragma
可以组合为一元运算符,例如:
_Pragma("first pragma") _Pragma("Second pragma")
关于c - 在 #define 中使用 openmp pragma,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6627462/