For my compiler tests, I need to generate this warning "Statement has no effect" in my test code. How can I do this?
Using VS cl.exe compiler
int main()
{
5; // Statement has no effect
return 0;
}
Edit 1 Tried on VC++ 2010
#include <iostream>
#pragma warning(default:4555)
int main()
{
5;
getchar();
return 0;
}
Output :
warning C4555:main.cpp(6): expression has no effect; expected expression with side-effect
NOTE: It seems VC++ 2010 has no C4705 warning on their list. MSDN Compiler Warnings