When debugging a program which uses (either C or C++), gdb
displays complex numbers as _M_value = xxx + yyy*I
(with a type of complex double
).
While debugging, I need to print that number multiplied by a factor.
The following does not work:
print a * 8.0
I get Argument to arithmetic operation not a number or boolean
.
Also, I cannot access the real and imaginary parts so that I can write a gdb macro to do the above. My current solution is to write a C function for manipulating complex values and arrays, and calling that function from gdb. Somehow, this just doesn't feel right.
If you use the standard C++ complex template then complex::real() and complex::imaj() should work.
my2c
Note : Was a comment ^^
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With