Search code examples
ccompiler-errorsfftw

error: lvalue required as left operand of assignment


I have a old sample of c programme that uses fftw to solve differential equations.

two lines of the programme which give error while compiling are:

creal(comp[i2+n_y*i1]) = c_zero + 1/15;
cimag(comp[i2+n_y*i1]) = 0.0;

Here, comp is a complex variable with creal, cimag being its real and imaginary parts. It is trying to assign value at some point(i2,i1).

which gives error

 **error: lvalue required as left operand of assignment**

I had this problem earlier also and fix was to replace creal with __creal__ or something, though I am not able to remember it. Can anyone tell me how can I get rid of the error? Any help will be appreciated.


Solution

  • To assign value to a complex number I did following which worked

    __real__(comp[i1+n*i2]) = ...
    __imag__(comp[i1+n*i2]) = ....