Visual Studio 2010 (C++): suppress C4706 warning temporarily

后端 未结 5 855
萌比男神i
萌比男神i 2021-02-13 17:33

When you compile the following C++ source file in Visual Studio 2010 with warning level /W4 enabled

#include   // for printf
#include 

        
5条回答
  •  逝去的感伤
    2021-02-13 18:10

    Instead of trying to hide your warning, fix the issue it's complaining about; your assignment has a value (the value on the left side of the assignment) that can be legally used in another expression.

    You can fix this by explicitly testing the result of the assignment:

    if ((result = strcmp(str0, str1)) != 0) 
    {
        printf("Strings are different\n");
    }
    

提交回复
热议问题