Public Group

This topic is 4879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey, I have a question. Is it acceptable to disable warnings in C++? Like, I have this warning that just tells me that it's truncated, would it be acceptable to disable that since it just tells me something that I could care less about? Thanks for any help in advance, -Lenox

##### Share on other sites
just cast the value and they'll go away :)

##### Share on other sites
Most of the time, these warning do not give you usefull informations. But there are weird cases where you actually want them to display this information. Your best bet is to go though your code, verify each warning, use the appropriate cast.

2: if you spoke about truncated symbol name
In VC6, symbol names are limited to 255 char in the debug files. When you use the stl, you get a lot of stupid warning about this. This specific warning can be safely disabled. To disable it in your project, go in the stdafx.h file and use:
#pragma warning(disable: WNUM)

Where WNUM is the warning number (I don't remember it).

HTH,

##### Share on other sites
Yes, it's acceptable. That's why it's just a warning.
Make sure that you always fix your warnings in some way though, otherwise you might just give up and start ignoring all of them.

However I've found that it's often best to acknowledge the warning by working around the problem (often with a cast) instead of disabling it completely. Otherwise there's a risk of missing potentially useful warnings of the same class.

If it still looks like a hack or you don't like being told what to do, you can always add comment about how the stupid compiler forced you to alter perfectly valid code.

If you're talking about the linked truncating symbols and not about potentially truncated integers, you're left with little choice other than to disable the warning itself (or switching to another compiler).

##### Share on other sites

" C4786: 'identifer' : identifer was truncated to '255' characters in the debug information. "

I mean, I probably shouldn't care about whether or not 'identifer' was truncated to 255 characters in the debug information.

[EDIT]
It's case #2 that Emmanuel stated. I'm using MSVC++ 6.0. I just put #pragma warning ( disable: C4786 ) in the file where I get the errors.
[/EDIT]

[EDIT2]

Oops, my bad. Posted wrong, it's #pragma warning (disable: 4786) without the letter. D'oh! :P

[/EDIT2]

Thanks for the help, ya'll.

-Lenox

• 10
• 10
• 9
• 48
• 12
• ### Forum Statistics

• Total Topics
631388
• Total Posts
2999715
×