Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: expected primary-expression before ‘int’

Tags:

c++

gcc

cilk

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

like image 862
user3668129 Avatar asked Nov 17 '25 08:11

user3668129


2 Answers

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.

like image 158
MicroVirus Avatar answered Nov 19 '25 21:11

MicroVirus


As mentioned above, support for cilk_for was added in gcc 5.0.

like image 23
Barry Tannenbaum - Intel Avatar answered Nov 19 '25 22:11

Barry Tannenbaum - Intel