Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fstream causing compiler errors

Status
Not open for further replies.

timmay3141

Programmer
Dec 3, 2002
468
US
I'm using fstream in an MFC app and I'm getting a really strange set of error messages. My code compiles fine not using anything involving fstream. However, if I #include <fstream> I suddenly have 103 errors. I don't even have to declare an fstream object - just #include the file. The error messages I get are basically all the same:

c:\program files\microsoft visual studio\vc98\include\fstream(218) : error C2143: syntax error : missing ';' before '}'
c:\program files\microsoft visual studio\vc98\include\fstream(213) : while compiling class-template member function 'void __thiscall std::basic_filebuf<char,struct std::char_traits<char> >::_Init(struct _iobuf *,enum std::basic_filebuf<char,
struct std::char_traits<char> >::_Initfl)'

What's the problem here?
 
Will the program compile if you use

#include <fstream.h>[\color] ?

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
Yes, #include <fstream.h> works fine. I just want to fix this problem because its generally a good thing for STL to be working properly :).
 
That problem is corrected by installing the latest ServPack (5) for VS6. You should then be able to just use the

#include <fstream>

If you choose to battle wits with the witless be prepared to lose.

[cheers]
 
Change any instances of <iostream.h> to <iostream>. You don't want to mix-'n'-match iostreams libraries (<header> is new-style, <header.h> is old-style and deprecated).
 
*hits head against wall*

Apparently you can't #include <fstream> in a MFC app - I tried it out in a console app and it worked fine...I probably should have checked that before posting this...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top