Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you turn off (specific) compiler warnings for any header included from a specific location?

I've got a third-party library that generates a ton of warnings, even under /W3. Is there a way for me to tell the compiler, "disable C4244 for any file included from this directory, or its subdirectories"? Of course, I don't want to disable the warning in our own codebase, nor do I want to have to track down every possible include and wrap it with #pragma warning(...

like image 239
moswald Avatar asked Jul 17 '10 17:07

moswald


3 Answers

I hate to answer my own question here, but I'm afraid that the "correct" answer in this case is: it's not possible.

like image 93
moswald Avatar answered Oct 25 '22 08:10

moswald


You can put flags e.g /wd4600 in VS Project Settings > Command-line Options to tell the complier to suppress specific Complier Warnings

like image 24
cpx Avatar answered Oct 25 '22 08:10

cpx


I'm not sure whether you meant you do not want to wrap your include statements with #pragma directives or did not want to spend time tracking down the right directive. If its the latter, then this is what I've done in the past:

#ifdef _MSC_VER
#pragma warning( disable : 4244 )
#endif

#include "MyHeader.h"

#ifdef _MSC_VER
#pragma warning( default : 4244 ) /* Reset to default state */
#endif
like image 30
Praetorian Avatar answered Oct 25 '22 10:10

Praetorian