• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 10262
  • Last Modified:

VC++ 6.0 disable warning C4786

I'm trying to disable a warning I'm getting when using STL and MFC template objects.
I have this code in my *.cpp file, and I've thrown #pragma all over it, and I'm still getting the warning.
#pragma warning(disable:4786)
#include <afxtempl.h>
#pragma warning(disable:4786)

CMap<int, int, CString, LPCTSTR> m_AcctMessList;
#pragma warning(disable:4786)
CMap<CString, LPCTSTR, int, int> m_SigMessList;
#pragma warning(disable:4786)

This is on a clients computer, and they keep they're VC++ header files on a server with READ-ONLY access, so I can't modify the VC++ include header files.

Isn't there a way to disable this from the Compiler option setting so it applies to all code compile for a specific project?

Or does anyone know of any other way to get rid of these warnings?

FYI:
I want to do this WITHOUT lowering my compiler warning level.
0
Axter
Asked:
Axter
  • 7
  • 5
  • 3
  • +3
2 Solutions
 
jkrCommented:
>>I can't modify the VC++ include header files.

That should not be necessary, somethig else must be going wrong. Have you tried a full rebuild (yes, I know that's a stupid Q, but...)?

>>I want to do this WITHOUT lowering my compiler warning level

C4786 is a level 1 warning :o)
0
 
AxterAuthor Commented:
>> (yes, I know that's a stupid Q, but...)?
Yes I did.


>>I want to do this WITHOUT lowering my compiler warning level
>>C4786 is a level 1 warning :o)

Yea.  What was MS thinking about!!!
0
 
jkrCommented:
This must be some sort of a setup problem - a simple test like

#include <afx.h>
#include <afxtempl.h>
#pragma warning(disable:4786)

void main () {

CMap<int, int, CString, LPCTSTR> m_AcctMessList;
CMap<CString, LPCTSTR, int, int> m_SigMessList;
}

compiles just fine without that warning. Any code involved you did not write that might turn that back on?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AxterAuthor Commented:
I got it worked out.

I had #include <afxtempl.h> already in my stdafx.h file, and this was getting pulled first without the disable #pragma.

What I dont' understand, is that I even put disable #pragma before #include "stdafx.h", so it should have disabled it anyway.
0
 
jimwassonCommented:
Unfortunately this doesn't always work. It is a known bug that Microsoft has not fixed. See
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q167355&
0
 
_corey_Commented:
Were you using pre-compiled headers?  If so, warnings are kept in the pch.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_consistency_rules_for_per.2d.file_use_of_precompiled_headers.asp ["Consistency Rules for Per-File Use of Precompiled Headers"]

corey
0
 
AxterAuthor Commented:
>>Were you using pre-compiled headers?  If so, warnings are kept in the pch.

I would think that would clear out after a full recompile.
0
 
AxterAuthor Commented:
>>Unfortunately this doesn't always work. It is a known bug that Microsoft has not fixed. See

Interesting link.
0
 
jimwassonCommented:
It has irritated me for years!
0
 
_corey_Commented:
What version of Visual Studio are you using?  It is claimed to be fixed in VS7+.

STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.

This problem was corrected in Microsoft Visual C++ .NET.

corey
0
 
AxterAuthor Commented:
My client uses VC++ 6.0.

I have 7.1 at home, but even there I mostly use 6.0 because I'm use to it.

I'm usually able to get rid of this warning, but every now and then it seems no matter what I do, I can't get rid of it.


>>It has irritated me for years!

It's very irritating, because I like to have a clean build with no warnings.
0
 
_corey_Commented:
Axter,

  I take this that this file you modified above wasn't the only source file in the project and not the only one including stdafx.h ?

corey
0
 
AxterAuthor Commented:
>>I take this that this file you modified above wasn't the only source file in the project and not the only one including stdafx.h ?

That's correct.
0
 
_corey_Commented:
Just an idea, in the source you're trying to fix specfically, throw in a hdrstop pragma right before the warning pragma and the offending header.  See if you can get VC++ to specifically parse that warning out there.

corey
0
 
jkrCommented:
I doubt that precompiled headers lead to that behaviour - that's why  asked about the 'Rebuild all' thing, since this also deletes the .pch files.
0
 
_corey_Commented:
Quite right, jkr.  It's the only idea I could come up with.  That and the hdrstop.

corey
0
 
rcarlanCommented:
I solved the darn warning C4786 problem by placing

#pragma warning(disable: 4786)

as the first line in stdafx.h and making sure all STL includes that I need (across the entire project) are placed in the stdafx.h


In other words, have all offending declarations in the precompiled header and disable the warning in it.


Radu
0
 
AxterAuthor Commented:
Thanks for everyone's input.
0
 
itsmeandnobodyelseCommented:
>>Were you using pre-compiled headers?  If so, warnings are kept in the pch.
>>>> I would think that would clear out after a full recompile.

Did you put the #pragma to stdafx.cpp as well?

If "Using Precompiled Header Through ...." is on, VC compiler simply ignores all statements from top to #include "stdafx.h" replacing that part by the info given by .pch file. Therefore a #pragma warning in that section was ignored.

Regards, Alex

0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 7
  • 5
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now