警告:"LPEVENT CItem::m_pkExpireEvent"和警告:格式"%d"需要类型"int",但参数 3 的类型为"double"

Warning: 'LPEVENT CItem::m_pkExpireEvent' and warning:format '%d' expects type 'int', but argument 3 has type 'double'

本文关键字:警告 类型 int double 参数 CItem LPEVENT pkExpireEvent 格式      更新时间:2023-10-16

多亏了社区和他的所有成员,我几乎完成了所有错误。

在这篇文章中,我将尝试包括所有剩余的错误。

  1. warning: unused variable 'sum':

    if (!m_pTable->GetDragonHeartExtValues(ds_type, grade_idx, vec_chargings, vec_probs))
    {
        return false;
    }
    int idx = Gamble(vec_probs);
    float sum = 0.f;
    if (-1 == idx)
    {
        sys_err ("Gamble is failed. ds_type(%d), grade_idx(%d)", ds_type, grade_idx);
        return false;
    }  
    
  2. warning: NULL used in arithmetic:

    const char * line = two_arguments(value_string, db_host[0], sizeof(db_host[0]), db_user[0], sizeof(db_user[0]));
    line = two_arguments(line, db_pwd[0], sizeof(db_pwd[0]), db_db[0], sizeof(db_db[0]));
    if (NULL != line[0])
    {
        char buf[256];
        one_argument(line, buf, sizeof(buf));
        str_to_number(mysql_db_port[0], buf);
    }  
    
  3. warning: comparison is always false due to limited range of data type:

    int j = 1;
    do
    {
        BYTE p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
        if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
            return false;
        if (m_pointsInstant.bItemGrid[p])
            if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
                return false;
    }
    while (++j < bSize);
    return true;
    
  4. warning: control reaches end of non-void function

  5. format '%d' expects type 'int', but argument 4 has type 'double':

    sprintf(buf, "dice(%d) prob(%d)", fDice, fProb);
    

很抱歉,如果不允许问多个问题,但即使我等了90分钟再问,结果也是一样的,希望他是积极的。

  1. 您声明了一个没有在任何地方使用的sum变量,因此可以将其删除。

  2. line[0]char,而不是指针,所以使用0''而不是NULL。

  3. 您正在将变量与变量数据类型的有效值范围之外的值进行比较。给定您显示的代码,这意味着DRAGON_SOUL_INVENTORY_MAX_NUM大于255,或者bSize小于int,等等。

  4. 函数具有非void返回类型,但编译器在函数的代码流中检测到一条路径,该路径可能会导致它跳过返回值。

  5. 不言自明。调用sprintf()时,您正在指定一个doublefProb变量),其中需要int。要格式化double值,必须使用上的浮动类型说明符,例如%lf%d说明符用于int值。

相关文章: