Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error using restrict keyword

In the following example:

void foo (double *ptr)
{
     const double * restrict  const restr_ptr=ptr;
}

I get this error:

error: expected a ";"      const double * restrict  const restr_ptr=ptr;
                                                      ^

I compile with -std=c99, using gcc 3.4

Any Ideas?

like image 442
vehomzzz Avatar asked Sep 08 '09 17:09

vehomzzz


1 Answers

In C++, restrict is not a keyword (except for Microsoft extensions). It doesn't mean what it does in C. It looks as though you tried to apply C99 mode to your C++ compiler. Use a C compiler to compile C code, and use a C++ compiler to compile C++. Neither language is a subset of the other.

like image 89
Rob Kennedy Avatar answered Sep 22 '22 09:09

Rob Kennedy