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

后端 未结 5 857
萌比男神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:15

    There is another solution which avoids the warning: the comma operator.

    The main advantage here will be that you don't need parentheses so it's a bit shorter than the !=0 solution when your variable name is short.

    For example:

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

提交回复
热议问题