"cout" strange errors

I had completed a small project yesterday and then I caught these strange errors :


main.cpp(13) : error C2872: 'cout' : ambiguous symbol
main.cpp(31) : error C2872: 'cout' : ambiguous symbol
main.cpp(36) : error C2872: 'cout' : ambiguous symbol
main.cpp(37) : error C2872: 'cout' : ambiguous symbol
main.cpp(64) : error C2872: 'cout' : ambiguous symbol
main.cpp(64) : error C2872: 'cout' : ambiguous symbol
main.cpp(64) : error C2872: 'cout' : ambiguous symbol
main.cpp(65) : error C2872: 'cout' : ambiguous symbol
main.cpp(107) : error C2872: 'cout' : ambiguous symbol
...............................................................
fatal error C1003: error count exceeds 100; stopping compilation


My program definition :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define BUFSIZE 4096 

#define LOOPTIME 1000000
#include <time.h>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <string.H>
#include <fcntl.h>
#include <fstream.h>
#include <stdlib.h>
//#include <mmsystem.h>
#include <windows.h>

using namespace std;


I totally don't know this "cout" case. The compiler "error C2872: 'cout' : ambiguous symbol"-??

What should I do? (Any help would be greatly appreciated.)
Last edited on
Can you provide a small program that still creates this issue? I would assume this might be due to incorrect includes or something...

By the way, fstream and string do not contain an .h suffix as they are C++ headers. You should also use c<name> instead of <name>.h for the C headers so that they will be properly wrapped inside the C++ namespace.
Thanks you, firedraco
But, my program has an another error.

ostream(354) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit


Edit :
1
2
		basic_ostream<_E, _Tr>& _O, const unsigned char *_X)
	{return (_O << (const char *)_X); }

How do I solve this problem?
Last edited on
Ok, there is definitely something weird going on. You shouldn't be getting errors like that (especially not in STL headers).

Can you try making a really simple program (like hello world) and include those headers and see if it still gives you those errors?
The program works Ok. But I don't really understand :
internal heap limit reached; use /Zm to specify a higher limit

Why this caused? Perhaps I used too many "cout" and "ostream"?
And how to solve it?
I've found "how to edit command-lines in project settings". But an error still appears :

Command line error D2004 : '/Zm' requires an argument

Hix... Any help?
Those errors should not be occurring; trying to fix them like that probably won't solve the underlying the problem with your program.

By
The program works Ok.
do you mean that you were able to create a hello world program that worked fine?
Of course, yes.
But can you explain the error? "heap" limited? Why?
Last edited on
C2872 error means that the cout function has been defined in two separate places and the compiler cannot determine which one to use. Try taking the

using namespace std;

out and prefixing each function you are using from the std: library with std:: i.e. std::cout

see:

http://msdn.microsoft.com/en-us/library/t57wswcs(v=vs.80).aspx
A bunch thanks, ajh32! And the last error :

ostream(354) : fatal error C1076: compiler limit : internal heap limit reached; use /Zm to specify a higher limit


1
2
	basic_ostream<_E, _Tr>& _O, const unsigned char *_X)
	{return (_O << (const char *)_X); }


If I change the command line it will show :
Command line error D2004 : '/Zm' requires an argument

??????

Infinite error loop??

#include <fstream.h> //Really ???
Well, I presume you have set a pre compiler setting /Zm but haven't specified a number for its argument for the memory limit, see:

http://msdn.microsoft.com/en-us/library/bdscwf1c(v=vs.80).aspx

But, as was stated before, this isn't fixing the problem. Do you have a memory leak in your program? Are you allocating memory on the heap and not freeing it? Try rebooting your PC to start with.
Wow, It's awful!!! I set /Zm 200 first but this parameter definition is invalid. So tried the /Zm200 and it's Okay. But the compiler needs /Zm500 (500 Mb) to compile and link the program properly. Why "my program needs so much "heap" memory"?
And, thanks ajh32 so much so much!! In my opinion you're really intelligent!!
Why thank you Jackson Marie, I like to help out where I can. I am a professional Software Engineer by profession, so that helps.
Topic archived. No new replies allowed.