警告:"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'
多亏了社区和他的所有成员,我几乎完成了所有错误。
在这篇文章中,我将尝试包括所有剩余的错误。
-
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; }
-
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); }
-
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;
-
warning: control reaches end of non-void function
-
format '%d' expects type 'int', but argument 4 has type 'double'
:sprintf(buf, "dice(%d) prob(%d)", fDice, fProb);
很抱歉,如果不允许问多个问题,但即使我等了90分钟再问,结果也是一样的,希望他是积极的。
-
您声明了一个没有在任何地方使用的
sum
变量,因此可以将其删除。 -
line[0]
是char
,而不是指针,所以使用0
或' '
而不是NULL。 -
您正在将变量与变量数据类型的有效值范围之外的值进行比较。给定您显示的代码,这意味着
DRAGON_SOUL_INVENTORY_MAX_NUM
大于255,或者bSize
小于int
,等等。 -
函数具有非void返回类型,但编译器在函数的代码流中检测到一条路径,该路径可能会导致它跳过返回值。
-
不言自明。调用
sprintf()
时,您正在指定一个double
(fProb
变量),其中需要int
。要格式化double
值,必须使用上的浮动类型说明符,例如%lf
。%d
说明符用于int
值。
相关文章:
- 警告:在函数返回类型 [-Wignore 限定符] 时忽略类型限定符
- 我在 C++ 代码中遇到错误警告:控制到达非空函数 [-Wreturn 类型] 的末尾
- 将不同类型的模板参数包提取到双精度向量中会产生警告
- 警告:左移计数 >= 在 C++ 中将字节流读取为双精度变量时的类型宽度
- OPENCL 警告:不兼容的指针类型将'float __global[16]'传递给类型为 '__global float4 的参数 *
- Clang 对使用的类型别名发出"unused type alias"警告
- 警告:函数使用不带尾随返回类型的'auto'类型说明符
- 编译器在 const ref 类型参数上使用临时对象时是否应该警告不安全的行为?
- MISRA 警告<复杂表达式隐式转换为不同的基本类型>
- 如何警告 C 中 void 指针上的参数不兼容的类型
- 由于非类型模板参数而具有零大小数组的类模板:如何防止警告
- 我的代码错误类型警告 1 警告 C4018 和更多错误
- 如何在代码块 IDE 上修复此警告,警告:按值 [-Wcatch-value=] 捕获多态类型"类 std::d omain_error"
- 编译错误:(警告:控制到达非空函数 [-wreturn 类型] 的末尾)
- 如何处理警告:从较小的整数类型int转换为int*
- 警告:格式"%d"需要类型为"int*"的参数,但参数5的类型为"in
- 在 C++ 中修复类型转换警告的最佳方法
- 模板类型推导警告返回对本地临时对象的引用
- 警告:在非标准布局类型'DerivedClass'上偏移
- 误报警告PVS Studio:V808类型的对象是创建但未使用的