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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Really weird error involving std vector... 1

Status
Not open for further replies.

nexius

Programmer
Jul 8, 2000
109
0
0
CA
Hi

Some code:
===================================================

#include <iostream>
#include <vector>
using namespace std;

class A
{
};

class r
{
};

class R
{
};

class Jim
{
};

class Jirm
{
};


int main()
{
vector < vector < int* > > a; // This is OK

vector < vector < A* > > b; // This is OK

vector < vector < R* > > c; // This is OK

//vector < vector < r* > > d; // This is not...

vector < vector < Jim* > > e; // This is OK

//vector < vector < Jirm* > > f; // This is not!!

return 0;
}

===================================================

Uncommenting the two commented lines will result in some warnings... because the both classes have an 'r' in its name..... WHY??

Maybe I'm going insane. Or it's too late. I'm going to sleep now before I bash my head against my monitor.

Any help appreciated...
-Steve {neXius}
 
I managed to compile the above uncommented withouth any warnings/errors.

> will result in some warnings

Well, you could be a bit more specific.

/Per
[sub]
&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;[/sub]
 
Maybe there is aome r from another charset, for example russian g is the english r. When writing C++ code use only english charset.

Ion Filipski
1c.bmp
 
warning C4786: 'std::vector<std::vector<CTesting *,std::allocator<CTesting *> >,std::allocator<std::vector<CTesting *,std::allocator<CTesting *> > > >::~vector<std::vector<CTesting *
,std::allocator<CTesting *> >,std::allocator<std::vector<CTesting *,std::allocator<CTesting *> > > >' : identifier was truncated to '255' characters in the debug information

I AM going insane... for some reason my example compiled today without linking errors (didn't yesterday). But when I changed the class name to 'CTesting' it gave me the same warning... (see above)

I'm so confused.
 
That is one of those warnings you can totally ignore. As you can see it says that the debug info is truncated to 255 character. No big deal.

Put a
Code:
#pragma warning(disable:4786)

before you include the STL stuff. (if you're using a stdaxf.h, put it before its includes)

>without linking errors
>it gave me the same warning

error != warning

/Per
[sub]
&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;[/sub]
 
Note that the warnings occur when the code is compiled. And since its just a warning the compilation will succeed.

If the code is already compiled, the warnings will not occur since the compiler is bright enough not to bother with code it knows it doesn't have to.

When you make some change to the code, for example by changing the class name, the code recompiles and the warnings are back. When you compile it again (without changing anyting) there won't be any warning.

Makes sense?

/Per
[sub]
&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;[/sub]
 
Alright thanks PerFnurt.

My only problem was that I didn't know what the warning meant, and so I thought it might be bad...

Actually I still don't know what it means, but as you say I can ignore it.

I finally looked it up on msdn and apparently disabling it with a 'pragma' won't work....


I can't actually test it though since I'm at work...

Maybe I'll just have to put up with the complaints... either that or upgrade to .NET.

Thanks again.
 
The pragma usually works, just put it in the right place :)

/Per
[sub]
&quot;It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure.&quot;[/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top