doesn't supply such packages, go to <ftp://ftp.gnu.org/gnu/readline/>
and compile it yourself.
-Problems with missing <sstream>
--------------------------------
-
-GCC-2.95.2 and earlier don't have support for this header. GiNaC can use
-<strstream> instead, but this may cause some trouble later. GCC-3.0 has a
-completely new implementation of the STL-headers (libstdc++-v3) and there,
-standard-conforming support for <sstream> is present. If you can't upgrade
-your compiler we recommend using the libstdc++-v2 <sstream> header by
-Magnus Fromreide. It was posted to the gcc-patches mailing list on
-November 21 2000: <http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01152.html>.
+Problems with missing standard header files
+-------------------------------------------
+
+Building GiNaC requires many standard header files. If you get a
+configure error complaining about such missing files your compiler and
+library are probably not up to date enough and it's no worth
+continuing. If the only file missing is <sstream>, however, there is
+a solution. GCC-2.95.2 and earlier don't ship with this file. A
+working implementation has been available since GCC-2.95.3. GCC-3.0
+and later have an even better, fully standard-conforming
+implementation, by default. If you are stuck with GCC-2.95.2 or
+earliear and you cannot upgrade your compiler we recommend obtaining
+the libstdc++-v2 <sstream> header written by Magnus Fromreide. It was
+posted to the gcc-patches mailing list on November 21 2000:
+<http://gcc.gnu.org/ml/gcc-patches/2000-11/msg01152.html>.
*/
#include "checks.h"
-
-#if defined(HAVE_SSTREAM)
-# include <sstream>
-#else
-# include <strstream>
-#endif
+#include <sstream>
static unsigned check_matrix_solve(unsigned m, unsigned n, unsigned p,
unsigned degree)
matrix X(n,p);
for (unsigned i=0; i<n; ++i) {
for (unsigned j=0; j<p; ++j) {
-#if defined(HAVE_SSTREAM)
ostringstream buf;
buf << "x" << i << j << ends;
x.push_back(symbol(buf.str()));
-#else
- char buf[4];
- ostrstream(buf,sizeof(buf)) << i << j << ends;
- x.push_back(symbol(string("x")+buf));
-#endif
X.set(i,j,x[p*i+j]);
}
}
vector<symbol> a;
vector<symbol> x;
for (unsigned i=0; i<n; ++i) {
-#if defined(HAVE_SSTREAM)
ostringstream buf;
buf << i << ends;
a.push_back(symbol(string("a")+buf.str()));
x.push_back(symbol(string("x")+buf.str()));
-#else
- char buf[3];
- ostrstream(buf,sizeof(buf)) << i << ends;
- a.push_back(symbol(string("a")+buf));
- x.push_back(symbol(string("x")+buf));
-#endif
}
lst eqns; // equation list
lst vars; // variable list
vector<symbol> a;
ex e;
for (unsigned i=0; i<size; ++i) {
-#if defined(HAVE_SSTREAM)
ostringstream buf;
buf << "a" << i << ends;
a.push_back(symbol(buf.str()));
-#else
- char buf[5]; // 'a' + 3 decimal digits + '\n'
- ostrstream(buf,sizeof(buf)) << "a" << i << ends;
- a.push_back(symbol(buf));
-#endif
e += a[i];
}
ex aux;
#include <sys/resource.h>
#include <stdlib.h>
-#include "config.h"
-#if defined(HAVE_SSTREAM)
-# include <sstream>
-#else
-# include <strstream>
-#endif
+#include <sstream>
#include <vector>
-using namespace std;
-
+#include "config.h"
#include "ginac.h"
+using namespace std;
using namespace GiNaC;
class timer {
LIBS=$save_LIBS
AC_SUBST(GINSH_LIBS)
-dnl Make sure all the necessary new-style headers are installed on the system.
-dnl If one of them cannot be found the system is probably not ANSI-conform
-dnl enough so trying the .h-style headers is a waste of time.
-AC_CHECK_HEADERS(iostream vector map string list typeinfo iterator stdexcept algorithm, ,
- AC_MSG_ERROR([need to have ANSI compliant headers]))
-dnl We need the sstream header. But since g++-2.95.n, n<3 does not provide
-dnl it, we must fall back to strstream, which, however, suffers from fixed
-dnl buffer sizes. So the fallback may produce a crippled library. NB: this
-dnl fallback will disappear in future versions.
-AC_CHECK_HEADERS(sstream strstream)
-if test "x${ac_cv_header_sstream}" = "xno"; then
- if test "x${ac_cv_header_strstream}" = "xno"; then
- AC_MSG_ERROR([I could not find the <sstream> or <strstream> header.])
- else
- GINAC_WARNING([I could not find <sstream>. <strstream> may cause trouble.])
- fi
-fi
+dnl Make sure all the necessary standard headers are installed on the system.
+AC_CHECK_HEADER(iosfwd, , GINAC_ERROR([The standard <iosfwd> header file could not be found.]))
+AC_CHECK_HEADER(iostream, , GINAC_ERROR([The standard <iostream> header file could not be found.]))
+AC_CHECK_HEADER(vector, , GINAC_ERROR([The standard <vector> header file could not be found.]))
+AC_CHECK_HEADER(list, , GINAC_ERROR([The standard <list> header file could not be found.]))
+AC_CHECK_HEADER(map, , GINAC_ERROR([The standard <map> header file could not be found.]))
+AC_CHECK_HEADER(string, , GINAC_ERROR([The standard <string> header file could not be found.]))
+AC_CHECK_HEADER(sstream, , GINAC_ERROR([The standard <sstream> header file could not be found.]))
+AC_CHECK_HEADER(typeinfo, , GINAC_ERROR([The standard <typeinfo> header file could not be found.]))
+AC_CHECK_HEADER(stdexcept, , GINAC_ERROR([The standard <stdexcept> header file could not be found.]))
+AC_CHECK_HEADER(algorithm, , GINAC_ERROR([The standard <algorithm> header file could not be found.]))
dnl We need to have Bruno Haible's CLN installed.
dnl (CLN versions >= 1.1.0 must have installed cln.m4 at a visible place,
#include <vector>
#include <stdexcept>
#include <string>
-
-#if defined(HAVE_SSTREAM)
#include <sstream>
-#elif defined(HAVE_STRSTREAM)
-#include <strstream>
-#else
-#error Need either sstream or strstream
-#endif
#include "numeric.h"
#include "ex.h"
#include "print.h"
#include "archive.h"
#include "debugmsg.h"
+#include "tostring.h"
#include "utils.h"
// CLN should pollute the global namespace as little as possible. Hence, we
// E to lower case
term = term.replace(term.find("E"),1,"e");
// append _<Digits> to term
-#if defined(HAVE_SSTREAM)
- std::ostringstream buf;
- buf << unsigned(Digits) << std::ends;
- term += "_" + buf.str();
-#else
- char buf[14];
- std::ostrstream(buf,sizeof(buf)) << unsigned(Digits) << std::ends;
- term += "_" + std::string(buf);
-#endif
+ term += "_" + ToString((unsigned)Digits);
// construct float using cln::cl_F(const char *) ctor.
if (imaginary)
ctorval = ctorval + cln::complex(cln::cl_I(0),cln::cl_F(term.c_str()));
// Read number as string
std::string str;
if (n.find_string("number", str)) {
-#ifdef HAVE_SSTREAM
std::istringstream s(str);
-#else
- std::istrstream s(str.c_str(), str.size() + 1);
-#endif
cln::cl_idecoded_float re, im;
char c;
s.get(c);
inherited::archive(n);
// Write number as string
-#ifdef HAVE_SSTREAM
std::ostringstream s;
-#else
- char buf[1024];
- std::ostrstream s(buf, 1024);
-#endif
if (this->is_crational())
s << cln::the<cln::cl_N>(value);
else {
s << im.sign << " " << im.mantissa << " " << im.exponent;
}
}
-#ifdef HAVE_SSTREAM
n.add_string("number", s.str());
-#else
- s << ends;
- std::string str(buf);
- n.add_string("number", str);
-#endif
}
DEFAULT_UNARCHIVE(numeric)
#ifndef __GINAC_TOSTRING_H__
#define __GINAC_TOSTRING_H__
-#include "config.h"
-
-#if defined(HAVE_SSTREAM)
#include <sstream>
-#elif defined(HAVE_STRSTREAM)
-#include <strstream>
-#else
-#error Need either sstream or strstream
-#endif
namespace GiNaC {
-// This should be obsoleted once <sstream> is widely deployed.
template<class T>
std::string ToString(const T & t)
{
-#if defined(HAVE_SSTREAM)
std::ostringstream buf;
buf << t << std::ends;
return buf.str();
-#else
- char buf[256];
- std::ostrstream(buf,sizeof(buf)) << t << std::ends;
- return buf;
-#endif
}
} // namespace GiNaC