Disable single warning error
#pragma warning( push ) #pragma warning( disable : 4101) // Your function #pragma warning( pop )
#pragma warning( push ) #pragma warning( disable : 4101) // Your function #pragma warning( pop )
If you’re using c99 or c++0x there is the pragma operator, used as _Pragma(“argument”) which is equivalent to #pragma argument except it can be used in macros (see section 6.10.9 of the c99 standard, or 16.9 of the c++0x final committee draft) For example, #define STRINGIFY(a) #a #define DEFINE_DELETE_OBJECT(type) \ void delete_ ## type ## … Read more
This is possible in GCC since version 4.6, or around June 2010 in the trunk. Here’s an example: #pragma GCC diagnostic push #pragma GCC diagnostic error “-Wuninitialized” foo(a); /* error is given for this one */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored “-Wuninitialized” foo(b); /* no diagnostic for this one */ #pragma GCC … Read more
It appears this can be done. I’m unable to determine the version of GCC that it was added, but it was sometime before June 2010. Here’s an example: #pragma GCC diagnostic error “-Wuninitialized” foo(a); /* error is given for this one */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored “-Wuninitialized” foo(b); /* no diagnostic … Read more