[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

g++272 libs, revisited.



As part of a homework assignment I've written a little program to do
arithmetic with fractions and mixed numbers, and I wanted to benchmark the
speed of various algorithms for finding 'gcd,' the greatest common divisor.
Not knowing how to do the timing piece, I started playing with gettimeofday.
Here's what I came up with:

#include <iomanip.h>
#include <sys/time.h>

int main()
{
 struct timeval *ThisTime;
 struct timezone *huh = 0;
 int i;
 long int k;
 i = gettimeofday(ThisTime, huh);
 cout << i << endl;
 k = ThisTime->tv_sec;
 cout << k;
}

On my basically stock model, off-the-shelf Debian 2.0 machine this builds with
the 'c++' call to egcs but seg faults on execution. Moving the snippet over to
a (yes) Win95 machine on which I've installed the GNU (DJGPP) gcc 2.7.2.1, it
not only builds but runs a DOS executable.

Aha sez I; I'll just whip the g++272 package onto the Debian box and be home
free. Did that, but it won't compile, complaining of many errors in the
headers, eg:

"/usr/include/g++/iostream.h:91: parse error before `__extension__'" and
"/usr/include/g++/iostream.h:208: parse error before `__extension__'."

Aha sez I; I don't have the libg++272-dev package on board - I'll just whip
that onto the Debian machine and be home free. Tried that, but I can't install
this package, just produce an dpkg error stating I already have libg++-2.8-dev
and that there's a conflict wrt libg++-dev that's provided by the latter.

I am most curious about:

1) How to write a little timing routine for benchmarking.
2) Why egcs can't build a working version of that piece of code.
3) How to get g++272 happily cohabiting with egcs on my Debian installation.

not necessarily (but pretty much) in that order.

TIA for any light shed on these or any other arcana! 


--
Bob Bernstein
at
Esmond, R.I., USA      <bernie@brainiac.com>  


Reply to: