By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

change to <iostream> causing compile errors

P: n/a
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.
Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Brett wrote:
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
Nov 17 '05 #2

P: n/a
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.

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:u$**************@TK2MSFTNGP09.phx.gbl...
Brett wrote:
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

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.