Click to See Complete Forum and Search --> : How to work around warning C4786


PBateman
September 25th, 2002, 03:09 PM
Hello,

i'm new to STL and tried to use it's map class:

map<String, DataNode*> m_map;

That produces warning C4768 with VC6, SP5, (identifier was truncated to '255' characters in the debug information).

Is there a way to suppress this warning or another workaround? I do not want to switch warnings off, but information gets lost in more than 200 warnings. Beside compilation becomes pretty slow.

thanks

cup
September 25th, 2002, 03:23 PM
#pragma warning(disable:4786)

the warning number is listed in the huge warning, so if your number is different simply replace 4786. Please note that the pragma should go just after the #include "stdafx.h"

PBateman
September 25th, 2002, 03:35 PM
Thanks, but disabling warning C4786 via pragma directive is not possible due to a VC6 bug not fixed.... Visual C++ v7 fixes these problems *wink wink*

But I think I' ve found something interesting, will be back soon

cup
September 25th, 2002, 03:38 PM
It must not be in a #include. It has to be in the source.

Mick
September 25th, 2002, 03:44 PM
Uhh *wink* *wink* I use VC6.0 SP5 and

#pragma warning(disable:4786)

all the time. And *wink* *wink* it works.

PBateman
September 25th, 2002, 03:48 PM
I' ve put the pragma in all affected cpp's and it works well *wink* *wink* ;-)

Thank You Very Much, Bye

Mick
September 25th, 2002, 03:53 PM
Well cup, I use mine in the header and it works for me. My cpp file for that header does use std::wstring which also will generate the warning and has no pragma defined. But whatever he got his issue solved :)

PBateman
September 25th, 2002, 04:29 PM
It also works fine putting it in front of all other includes in stdafx.h.

Good night...

proxima centaur
September 25th, 2002, 05:06 PM
In a big project we have at work, we're getting this warning even when using the #pragma keyword in every place imaginable. We've kind of given up on these. We're using VC++6. What a ****!

Edit: **** == a place where belzhebut dwelves :p

cup
September 26th, 2002, 12:37 AM
I've found that it doesn't work when I do a full system build but it does work when I'm doing individual builds. Maybe this was the bug that PBateman was talking about.

Someone once explained why this was happening but I was new to VC++ then and it was way over the top of my head. At that time, I was still trying to figure out what to click on.

Mick
September 26th, 2002, 10:25 AM
Well I work on a large project doing full builds, and we still don't get the errors (and trust me before I went in and put the #pragma's when I started at this company it was a build mess!). But there is too many differences between everyones' configuration here. Did you try #pragma in all cpp and .h's. I doesn't hurt ;) It's probably your hitting the definition before your #pragma kicks off.

proxima centaur
September 26th, 2002, 10:30 AM
No, there are just too many files to justify the task of adding the #pragma in everyone of them!

It is in every .h and .cpp where a STL container is found though, but it seems the compilor is having a hard time when the include file is included in another .h which is included in another .h and so on... it seems the farthest it gets from the #pragma, the most likely the warning reappears.

Weird.

Mick
September 26th, 2002, 11:48 AM
*lol* sorry I meant in every file dealing with STL. That's how i have it. It's not probably worth the time for you to try and unwind the headers, unfortunetly I will have to do that myself here, because the headers are just a #include mess 2. I don't look forward to that. Alot of people are just too lackadaisical when it comes to headers file IMHO.

proxima centaur
September 26th, 2002, 12:52 PM
:p :D ;) :p

Indeed. #include is a bloody **** when it's not done properly. I hate it when the code comes down to the syndrome:

change a character in a .h and have to recompile the whole thing

However, in order not to do that, maybe we all have to go throuhg it... so that we hate it so much we never do the same? :)