strstream and ostrstream with new g++

B

b83503104

Hi,

An old code is using stuff like
#include <strstream.h>
ostrstream *m_actionStream;
and the compiler complained syntax error before `*' token

I followed some previous posts and tried things like
#include <strstream.h>
or
#include <sstream>
and
std::eek:stringsteam *m_actionStream;
but all in vain.

Is there any simple way (adding a couple of lines) to make the old code
work, instead of rewriting everything?
Thanks
 
J

Jonathan Turkanis

Hi,

An old code is using stuff like
#include <strstream.h>
ostrstream *m_actionStream;
and the compiler complained syntax error before `*' token

I followed some previous posts and tried things like
#include <strstream.h>
or
#include <sstream>

Try #include said:
and
std::eek:stringsteam *m_actionStream;
but all in vain.

Is there any simple way (adding a couple of lines) to make the old
code work, instead of rewriting everything?
Thanks

Jonathan
 
D

Dietmar Kuehl

An old code is using stuff like
#include <strstream.h>

This header is no called <strstream> and it is deprecated. However,
deprecation just means that you should probably not use it in new
code and you might want to consider replacing it in old code if you
are working on it anyway.
ostrstream *m_actionStream;

The 'ostrstream' class is know declared in namespace 'std', i.e.
want to use one of the following:

- 'std::eek:strstream* m_actionSteram;'
- 'using std::eek:strstream;' and leave the definition as is.
- 'using namespace std;' and leave the definition as is.

(listed in order of my preference).

The advantage of the latter two approach over the first one is that
you can put the stuff at just one location, e.g. immediately after
the include directive. However, you should not use the 'using'
approaches at the global scope in headers (the name of your
variable seems to indicate that it is actually a member of a class).
Is there any simple way (adding a couple of lines) to make the old code
work, instead of rewriting everything?

Essentially, this should do the trick:

| #include <strstream>
| using std::eek:strstream;

If this does not work, please post a complete code excerpt which
displays the problem (and has no other problems...).
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top