I agree it's best to eliminate all warnings. If you're getting thousands of warnings you should prioritize your fixes.
Start be setting your compiler to the lowest warning level. These warnings should be the most important. When those are fixed, increment your warning level and repeat until you reach the highest warning level. Then set your compile options such that warnings are treated as errors.
If you find a warning that you suspect is safe to ignore, do some research to verify your theory. Only then disable it and only in the most minimal way possible. Most compilers have #pragma
directives that can disable/enable warnings for just a portion of a file. Here's a Visual C++ example:
typedef struct _X * X; // from external header, not 64-bit portable
#pragma warning( push )
#pragma warning( disable: 4312 ) // 64-bit portability warning
X x = reinterpret_cast< X >( 0xDDDDDDDD ); // we know X not 64-bit portable
#pragma warning( pop )
Note that this only disables the warning for a single line of code. Using this method also allows you to do simple text searching of your code in the future to make changes.
Alternatively you can usually disable a particular warning for a single file or for all files. IMHO this is dangerous and should only be a last resort.