编译器错误 C3054
当前在泛型类或函数中不支持“#pragma omp parallel”
注解
此错误在 Visual Studio 2022 及更高版本中已过时。
示例
下面的示例生成 C3054。
// C3054.cpp
// compile with: /openmp /clr /c
#include <omp.h>
ref struct MyBaseClass {
// Delete the following 7 lines to resolve.
generic <class ItemType>
void Test(ItemType i) { // C3054
#pragma omp parallel num_threads(4)
{
int i = omp_get_thread_num();
}
}
// OK
void Test2() {
#pragma omp parallel num_threads(4)
{
int i = omp_get_thread_num();
}
}
};