views:

195

answers:

2

Hi,

I'm wondering if there's a way to disable all warnings on a specific file (for example, using a preprocessor directive).

I'm using CImg.h and I want to get rid of the warnings involving that code.

I'm compiling both with VS (the version for Windows) and gcc (the Linux one), so I would like to have a generic way...

Thanks!

A: 

Look into #pragma warning.

+2  A: 

You can do it using #pragma in Microsoft compiler:

http://msdn.microsoft.com/en-us/library/2c8f766e%28VS.80%29.aspx

Something like this:

#pragma warning (push, 0)

//....header file

#pragma warning (pop)

Can't help you with gcc compiler, some info here: http://stackoverflow.com/questions/965093/selectively-disable-gcc-warnings-for-only-part-of-a-translation-unit

EDIT EDIT Try push, 0.

Igor Zevaka
But #pragma warning expects the number/code of the warning you want to disable... how would you disable *all*?Thx for the reply.
huff
Almost! Warning level 1 still produces something. Fortunately, trying #pragma warning (push, 0) *does* work (though that level is not specified on the msdn page).Now for a gcc answer... (though you earned the correct answer -- you can edit it to be more correct :D)
huff
Oh, awesome, I thought of trying level 0 but haven't found a level 1 warning to test on...
Igor Zevaka
Anyway it seems to malfunction somehow: when poping the pushed state, doesn't seem to reenable the warning level established by the CL parameters -weird, but I guess that it would not fail if I set the warning level with another #pragma... well, I'll see where it goes...
huff