Hello there, I'm trying to compile a project in Visual Studio 2005 and the compiler finds errors in the file fstream.h. Some of them are:

c:\program files\microsoft visual studio\vc98\include\fstream.h(88) : error C2872: 'streambuf' : ambiguous symbol

c:\program files\microsoft visual studio\vc98\include\fstream.h(89) : error C2872: 'streampos' : ambiguous symbol

c:\program files\microsoft visual studio\vc98\include\fstream.h(89) : error C2872: 'streamoff' : ambiguous symbol

c:\program files\microsoft visual studio\vc98\include\fstream.h(106) : error C2872: 'streambuf' : ambiguous symbol


First of all, do header files (the ones of the program) have mistakes, or did I something wrong?

What can I do to fix it?

What else is in your code?
Did you define those symbols yourself?

Post a minimal complete program which demonstrates the problem.

fstream.h in Visual Studio 2005? Impossible! Your program gets old stream library includes (with .h names) in old Visual Studio include directory. Check up your installation environment. May be, you try to compile old (legacy) project.

I searched at the include folder and I saw that there is the fstream.h file.
I use the #include <fstream.h> header

Maybe I try to compile in an old type compiler (I don't know)

Also there are 2 more errors for these:

//set up an input stream
ifstream input;
input.open (imagefile, ifstream::in);

error C2872: 'ifstream' : ambiguous symbol


//open the output file
ofstream output;
output.open (outputfile, ofstream::out);

'ofstream' : ambiguous symbol

Also there are 2 more errors for these:

//set up an input stream
ifstream input;
input.open (imagefile, ifstream::in);

error C2872: 'ifstream' : ambiguous symbol


//open the output file
ofstream output;
output.open (outputfile, ofstream::out);

'ofstream' : ambiguous symbol

Why don't you just use fstream rather than fstream.h , even if VS 2005 lets you use fstream.h ? I know next to nothing about fstream.h except that my compiler never misses an opportunity to warn me not to use it. Changing to an old compiler so you can compile code with deprecated headers instead of trying to change to a new header seems like the wrong strategy to me.

This question has already been answered. Start a new discussion instead.