Reputation: 11
In the block definition for my custom SDR transceiver hardware I use the following complex variable:
gr_complex complexSample;
In my code, which has worked successfully for two years before a recent upgrade to the latest gnuradio release, I use the following assignments:
complexSample.real() = realInt;
complexSample.imag()= imagInt;
However, when I try to compile now, I get the following error:
error: lvalue required as left operand of assignment
Frustratingly, if I remove the pair of parentheses, I get the following error:
error: invalid use of member function 'void std::complex::imag(float)' (did you forget the '()'? )
The original version of gnuradio
I have been using is 3.7.5-5, and the latest I have upgraded to is: 3.7.10.1-2.
Has something significant changed between these two releases which could explain this difference in behaviour?
If so, what is the solution?
Could this be something to do with 'Volk integration' (whatever that is...).
Upvotes: 1
Views: 1624
Reputation: 36442
No, GNU Radio didn't change gr_complex
. It's still but an alias for std::complex<float>
.
What probably has changed is that you're now using a compiler set to C++14, and that makes std::complex<float>.real()
return a const that you can't assign to. (I think that's what happens.)
You should either just construct the value like you mean to, i.e.
gr_complex foo(realpart, imagpart)
or use the setters
gr_complex foo;
foo.real(realpart);
foo.imag(imagpart);
Upvotes: 3
Reputation: 179991
As the error message shows, gr_complex
is a typedef for std::complex<float>
. That means the .real()
and .imag()
methods are getters, not setters.
That's not what you want anyway. You just want to assign the number, not its separate components: complexSample = gr_complex{realInt, imagInt}
.
Upvotes: 2