本文介绍了错误C3017:在OpenMP中的终止测试'for'语句具有不正确的形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有一个for循环,其中定义了所有变量

I have a for loop that has all variables defined

#pragma omp parallel for
for(long long l = 1; l<=sqrtt; l++) ...

code> / openmp 命令行选项在Visual Studio 2012中,它给我

When I compile this with the /openmp command line option in Visual Studio 2012, it gives me

error C3017: termination test in OpenMP 'for' statement has improper form

我不知道为什么'for'语句有不正确的形式

I don't know why 'for' statement has improper form.

对于OpenMP的语句,如何将其应用于我的for循环?

What is a proper for statement to OpenMP? How do I apply it to my for loop?

推荐答案

标准为 for-loop 构造规定了非常严格的格式(参见第39页):

The OpenMP 3.1 standard prescribes a very strict form for the for-loop construct (see pag.39):

for (init-expr; test-expr; incr-expr) structured-block

特别地, test-expr 必须类似以下之一:

In particular, test-expr must look like one of the following:

var relational-op b
b relational-op var

其中 relational-op <,< =,>,  = b 是与var类型兼容的类型的循环不变性表达式。

where relational-op is one of <,<=,>,>= and b is a loop invariant expressions of a type compatible with the type of var.

除此之外,您必须确保:

Other than that you must ensure that:

所以,回到你的情况,我会检查 sqrtt 是一个循环不变的,并且所有线程都有相同的值。

So, coming back to your case, I would check sqrtt to be a loop invariant and to have the same value for all threads.

long long 在C ++ 11之前的C ++中不是标准的, =http://stackoverflow.com/a/2836891/771663> SO上的此问题。

long long isn't standard in C++ prior to C++11, see for instance this question on SO.

这篇关于错误C3017:在OpenMP中的终止测试'for'语句具有不正确的形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 10:57