//Program tested on Microsoft Visual Studio 2008 - Zahid Ghadialy
//This example shows how to suppress warnings using #pragma
#include<iostream>
using namespace std;
class error
{
public:
error(string s)
{
info = s;
}
private:
error();
string info;
};
#pragma warning( disable : 4290 )
int someFunc(void) throw (error)
{
return 1;
}
#pragma warning( default : 4290 )
int someOtherFunc(void) throw (error)
{
return 1;
}
int main()
{
return 0;
}
Here, for 'someOtherFunc', the compiler will generate a warning:
warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
but a similar warning for 'someFunc' wont be generated because we have already suppressed it using the #pragma.
No comments:
Post a Comment