Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

#pragma warning is not suppressing a warning

One of my .cpp files is generating warning C4275 due to a 3rd-party header I #include... (the warning is triggered due to a DLL-export class inheriting from a non-DLL-export class as far as I can tell).

I added the line:

#pragma warning(disable : 4275)

As the first line of my .cpp file and yet the warning is still being generated. This is on VC++ 2008, and no PCH is in use.

Why is my #pragma not working, and (other than changing the 3rd-party code) how can I address this?

like image 430
Mr. Boy Avatar asked Nov 13 '11 17:11

Mr. Boy


2 Answers

Generate a preprocessed file and you'll probably find that some other header file's re-enabling the warning.

like image 175
Raymond Chen Avatar answered Oct 21 '22 16:10

Raymond Chen


I haven't seen this particular warning, but in Visual Studio, you can disable specific warnings via project properties (i.e., not pragma). Disabling them that way seems to be "stronger" than disabling them via a pragma. You might do that for just the one file you're using.

Of course, warnings frequently tell you something useful, so this would really be a last resort.

like image 1
Michael Avatar answered Oct 21 '22 17:10

Michael