if we enable "-Wall -Werror" on Virtual C++, Virtual C++ will report all warnings and take it as error.
But you want to ignore some warnings in some cases. So we need to find a way to ignore warnings. Virtual C++ provide '#pragma warning( xxx)' to do it.
Here is the example:
#pragma warning( push )
#pragma warning( disable : 4100 )
int main(int argc, char** argv)
{
#pragma warning( pop )
#pragma warning( push )
#pragma warning( disable : 4101 )
int a;
#pragma warning( pop )
printf("hello world\n");
return 0;
}
In this code, we ignore two warnings. first is 4100, second is 4101.
4100 is parameter is not used.
4101 is variable is not used.
For GCC, we use __attribute__((unused)) for both unused parameters and variables.
|