Sign in to follow this  

Question about disabling warnings

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
1: Assuming your are speaking about truncated data
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 this post


Link to post
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 this post


Link to post
Share on other sites
I'm talking about this one:

" 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

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this