zoukankan      html  css  js  c++  java
  • 关于warning: suggest parentheses around assignment used as truth value [-Wparentheses]|的解决方法

    今天,在调试的时候一直出现warning: suggest parentheses around assignment used as truth value

    代码如下:

        if(startTime==0)
        {
            while(startTime=time((time_t*)NULL)==-1);

        }

        while(currentTime=time((time_t*)NULL)==-1);


        timedif=currentTime-startTime;

        if((strlen(cookie)<5)||(timedif>600))
        {
            startTime=currentTime;
            command_login();//登录操作
        }

    改成像下面这样子就好了

        if(startTime==0)
        {
            while((startTime=time((time_t*)NULL))==-1);

        }

        while((currentTime=time((time_t*)NULL))==-1);


        timedif=currentTime-startTime;

        if((strlen(cookie)<5)||(timedif>600))
        {
            startTime=currentTime;
            command_login();//登录操作
        }

    如果在一个括号里面又进行判断,又进行赋值,赋值的语句应该放到一个单独的括号里面。

  • 相关阅读:
    2017.4.6下午
    2017.4.6上午
    2017.3.31下午
    2017.4.5下午
    2017.4.5上午
    2017.4.1上午
    2017.3.31上午
    2017.3.28下午
    2017.3.28上午
    3.28上午
  • 原文地址:https://www.cnblogs.com/thegodofthunder/p/7239557.html
Copyright © 2011-2022 走看看