Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] CDT+GDB crash when Debug programs include "complex number"

Hello everyone,

I m using cdt3.0 + MinGW on a WindowXP, When display the varable of
complex number while debuging. gdb.exe encountered a problem causing
gdb crash.

anybody know how to make it work?

thank you!

the sample code is here:
========================================
#include <stdio.h>
#include <math.h>
#include <complex>
#include <iostream>
#include <stdlib.h>

using namespace std;

double angle2pi (complex < double >temp); // 0-2pi version of function angle

int main (void)
{
  complex < double >im = complex < double >(0.0, 1.0);
  double angle;
  angle = angle2pi (im);
  std::cout << angle << std::endl;
  return 0;
}

 double angle2pi (complex < double >temp)
  {
    double MOD = abs (temp) + 1e-20;
    double Angle = 0, Angle1 = real (temp) / MOD, Angle2 = imag (temp) / 
MOD;
    double pi = 3.1415926535897932384626433832795;
    if ((Angle1 >= 0) && (Angle2 >= 0))
      Angle = acos (Angle1);
    if ((Angle1 < 0) && (Angle2 >= 0) & (Angle2 <= 1))
      Angle = pi - acos (-Angle1);
    if ((Angle1 <= 0) && (Angle2 < 0))
      Angle = acos (-Angle1) + pi;
    if ((Angle1 > 0) && (Angle2 < 0))
      Angle = 2 * pi - acos (Angle1);

    return Angle / pi * 180;
  }

========================================
the makefile here
------------------------
test : test.o
 g++ -o test test.o -L -lstdc++
test.o : test.cpp
 g++ -g -ggdb -c test.cpp
------------------------


Back to the top