[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug Report
From: |
Hans Aberg |
Subject: |
Re: Bug Report |
Date: |
Wed, 2 Jan 2002 20:02:11 +0100 |
At 10:17 -0800 2002/01/02, Jim Leary wrote:
>On 1/1/02, I downloaded 4.0.tar.gz(USA EAST). I am especially
>interested in multiple precision integers in C++.
... When I ran
>
>info -f /gmp.info
>
>the first sample program was that listed below. This program was
>found in the menu path * C++ Class Interface and
>* C++ Interface General. When I attempted to
>compile that program, I got the compiler errors listed below the
>source code.
...
>gmpxx.h:2788: undeclared variable `ostrstream' (first use here)
I haven't tried GMP 4, but a common problem in older C++ code is that it
has not been update for the 1998 standard, which puts all standard library
constructs in the namespace std. A C compatibility header <cfoo> also does
that, and <foo.h> also calls <cfoo>, but then adds a "using <name>"
directive for each C name in the <cfoo> header.
It means that the name is nowadays std::cout, and the program should look like
#include "gmpxx.h"
#include <iostream>
int main(void)
{
mpz_class a, b, c;
a = 1234;
b = "-5678";
c = a+b;
std::cout << "sum is " << c << "\n";
std::cout << "absolute value is " << abs(c) << "\n";
return 0;
}
or:
#include "gmpxx.h"
#include <iostream>
int main(void)
{
mpz_class a, b, c;
a = 1234;
b = "-5678";
c = a+b;
using std::cout;
cout << "sum is " << c << "\n";
cout << "absolute value is " << abs(c) << "\n";
return 0;
}
>I looked inside gmpxx.h and noticed that the declaration of
>strstream is commented out at line 39. By putting back this
>declaration with
>
>#include <strstream>
The <strstring> header is deprecated; instead use <sstream> and the
stringstream classes (also in namespace std).
Hans Aberg