change to <iostream> causing compile errors

B

Brett

Hi,

I'm compiling an old project under the 'new' visual studio 7.1.3088.

I changed the line:
#include <iostream.h>
to
#include <iostream>

and now I get a stack of errors, some of which are:

stdexcpt.h(56) : error C2143: syntax error : missing ';' before '&'
stdexcpt.h(56) : error C2433: 'ostream' : 'inline' not permitted on data
declarations
stdexcpt.h(56) : error C2501: 'ostream' : missing storage-class or type
specifiers
stdexcpt.h(56) : error C2065: 'os' : undeclared identifier
stdexcpt.h(56) : error C2059: syntax error : 'const'
stdexcpt.h(57) : error C2143: syntax error : missing ';' before '{'
stdexcpt.h(57) : error C2447: '{' : missing function header (old-style
formal list?)

The code for those lines read as follows

inline ostream &operator<<(ostream &os, const mwException &except)
{
if (except.type()) os << except.type() << endl;
const char *file =
(except.source() ? except.source() : "No File Info.");
os << "Exception! File: " << file << ", Line: "
<< except.where() << endl;
os << " " << except.what() << endl;
// Print exception-class-specific message
if (except.post() != 0)
os << except.post() << endl;
return os;
}



I've tried to include <ostream> as well, but that didn't help.

Thanks,
Brett.
 
C

Carl Daniel [VC++ MVP]

Brett said:
Hi,

I'm compiling an old project under the 'new' visual studio 7.1.3088.

I changed the line:
#include <iostream.h>
to
#include <iostream>

Add

using namespace std;

And you'll be a lot closer to a drop-in replacement of <iostream.h> with
<iostream>

There may still be a thing or two that needs tweaking (particularly if
you're opening streams and not just using a stream that was handed to you,
like cout or cin). But add the using declaration and try again, it'll be
easier to spot what else needs to change when you get rid of all the
namespace related noise.

I'm assuming that you're also #includeing <stdexcept.h>, be sure to change
this to #include <stdexcept> as well.

-cd
 
B

Brett

Yep, that was it.

You were too quick, I was just about to post to the group to say don't
bother...honest!

Thanks,
Brett.
 

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

Top