c++gcccilk

error: expected primary-expression before ‘int’


I'm using: gcc --version gcc (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2

I'm trying to compiler the following program:

#include <iostream>
#include <cilk/cilk.h>

using namespace std;

int main(){

    cout << "\nStart\n";
    cilk_for (int i = 0; i < 10; i++) {
        cout << "I = " << i;
    }

}

But get the following error:

g++ -fcilkplus Cilk_1.cpp 
Cilk_1.cpp: In function ‘int main()’:
Cilk_1.cpp:9:12: error: expected primary-expression before ‘int’
  cilk_for (int i = 0; i < 10; i++) {
            ^
Cilk_1.cpp:9:23: error: ‘i’ was not declared in this scope
  cilk_for (int i = 0; i < 10; i++) {
                       ^

What is wrong ?

Thanks


Solution

  • From the link Chris gave in the comments, it seems GCC 4.9 supports all features of the cilk extensions except _Cilk_for out of the box. Therefore, your compiler (GCC 4.9) does not have cilk_for support.