g++296: no matching function for call to istrstream::str()

A

A. Farber

Hi,

I'm trying to port a bigger program from Visual C++
to Linux and after rewriting few Visual C++ functions
(strnicmp, filelength, findnext, etc.) I'm finally
down to just one (!) error message and now I'm stuck :-(

Does anybody please know, what could this error mean:

h_utl.cpp: In function `istrstream &operator>> (istrstream &, TVersion &)':
h_utl.cpp:108: no matching function for call to `istrstream::str ()'

Here is the mentioned line from the h_utl.cpp:

istrstream &operator>>(istrstream &is, TVersion &aVersion)
{
char *str=is.str();

When I look into the header /usr/include/g++3/strstream.h
(yes, I have to use g++296, the newer gcc does not work)
there is an str() function in the friend class:

class strstreambuf : public streambuf
{
struct _IO_str_fields _s;
friend class istrstream;
.....
public:
.....
char *str();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::eek:ut);
};

class istrstream : public strstreambase, public istream {
public:
istrstream(const char*, int=0);
};

But how to call it? Do I need some switch for g++296?
Please help the C++ idiot. And no, I can not rewrite that program.

Regards && merry Xmas
Alex
 
V

Victor Bazarov

A. Farber said:
I'm trying to port a bigger program from Visual C++
to Linux and after rewriting few Visual C++ functions
(strnicmp, filelength, findnext, etc.) I'm finally
down to just one (!) error message and now I'm stuck :-(

Does anybody please know, what could this error mean:

h_utl.cpp: In function `istrstream &operator>> (istrstream &, TVersion &)':
h_utl.cpp:108: no matching function for call to `istrstream::str ()'

It can only mean one thing: your 'istrstream' implementation does not have
the 'str' function, which is very strange.
Here is the mentioned line from the h_utl.cpp:

istrstream &operator>>(istrstream &is, TVersion &aVersion)
{
char *str=is.str();

When I look into the header /usr/include/g++3/strstream.h
(yes, I have to use g++296, the newer gcc does not work)

What do you mean "does not work"? Thousands of people use "the newer gcc"
and are happy about the improvements...
there is an str() function in the friend class:

class strstreambuf : public streambuf
{
struct _IO_str_fields _s;
friend class istrstream;
.....
public:
.....
char *str();
virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::eek:ut);
};

class istrstream : public strstreambase, public istream {
public:
istrstream(const char*, int=0);
};

But how to call it? Do I need some switch for g++296?

We know nothing about switches. Try gnu.g++.help.
Please help the C++ idiot. And no, I can not rewrite that program.

How can we help you if you cannot rewrite the program?

You could try to call the 'str' function of the stream buffer:

char *str = is.rdbuf()->str();

but in your version I cannot be sure what's happening since you're using
a deprecated version of string-based streams and a buggy compiler.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top