uint8_t NetRSSI=0;
uint8_t NetBer=0;
uint8_t failtime=0;

sscanf(&USART_RX_BUF[0],"%*s%u,%u",&NetRSSI,&NetBer);//此句警告 warning:  #181-D: argument is incompatible with corresponding format string conversion。意思是NetRSSI,NetBer这两个变量的类型与sscanf中的类型不符。

当然可以忽略,因为如果USART_RX_BUF中的字符确实在0-255以内可以得到正确的结果,但是。。。。此处不能忽略。

因为有

uint8_t failtime=0;

这个变量类型定义。

我之前忽略后,发现scanf赋值给上述变量的值并没有转换成unsigned char,而是将int后面的3个字节覆盖掉了failtime的内存位置,导致只要一执行上述的ssanf语句后failtime立即被清零。

修改后的为

uint32_t NetRSSI=0;
uint32_t NetBer=0;
uint8_t failtime=0;

编译后既不警告,运行时也不会出错了。

在此提醒,不可轻易忽略警告,特别是涉及到不同长度的变量转换时。

解决warning: #181-D: argument is incompatible with corresponding format string conversion警告的更多相关文章

  1. 解决:Oracle 异常 ORA-01861: literal does not match format string(字符串格式不匹配)

    今天在写存储过程的时候,老是报一个错.如下,记录下来,以供日后查阅. 报错:  Oracle 异常 ORA-01861: literal does not match format string(字符 ...

  2. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result

    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in 解决方案:$sql = ...

  3. PHP学习 fwrite:Warning: fwrite(): supplied argument is not avalid stream resource in

    使用fwrite报错:Warning: fwrite(): supplied argument is not avalid stream resource in 解决方法:文件权限的问题,文件需要77 ...

  4. tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end with a '/'. The path [/] does not meet these criteria and has been changed to []

    tomcat 7 WARNING: A context path must either be an empty string or start with a '/' and do not end w ...

  5. 报错The "chunk" argument must be one of type string or Buffer. Received type object

    报错内容: TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or ...

  6. 通俗易懂地解决中文乱码问题(2) --- 分析解决Mysql插入移动端表情符报错 ‘incorrect string value: '\xF0...

    原文:[原创]通俗易懂地解决中文乱码问题(2) --- 分析解决Mysql插入移动端表情符报错 'incorrect string value: '\xF0... 这篇blog重点在解决问题,如果你对 ...

  7. tensoboard [Errno 22] Invalid argument 以及 Invalid format string问题解决

    Invalid argument 问题解决: 需要保证tensorboard与tensorflow版本一致. Invalid format string 问题解决: 修改 manager.py 文件中 ...

  8. 解决warning: incompatible implicit declaration of built-in function 'malloc'

    因为代码中使用了malloc函数和字符串函数.编译时出现错误 warning: incompatible implicit declaration of built-in function 'mall ...

  9. opencv编程解决warning C4003: “max”宏的实参不足

    忘了把程序出错的代码附上了,运行修改好的程序才发现的.只好把问题的代码大致写一下了: warning C4003: “min”宏的实参不足 error C2589: “(”:“::”右边的非法标记 e ...

随机推荐

  1. nor flash之频率限制

    背景 支持一款nor flash时,出于性能考虑,一般会查看其nor支持的最高频率以及主控端spi控制器的最高频率,以选择一个合适的运行频率. 对于一款主控支持多款flash的情况,还得考虑好兼容性等 ...

  2. 记录安装Python第三方包“tesserocr”的方法和遇到的坑

    1. 环境: 系统环境:Win7 32 位系统 Python版本: 3.6.5        虚拟环境为:Miniconda3 2. 共需要安装的模块: a. tesserocr b. tessera ...

  3. 【题解】BZOJ1034 [ZJOI2008]泡泡堂BNB(贪心)

    [题解]BZOJ1034 [ZJOI2008]泡泡堂BNB(贪心) 考虑直接模拟田忌赛马... 我的最小比你的大,直接上 我的最大比你的大,直接上 otherwise,我小换你大 考虑最劣,由于每次比 ...

  4. $CF1063B\ Labyrinth$ $01$最短路/$01BFS$

    \(Des\) 有一个网格图,上面的格子分为空地和障碍,障碍是不可以走的.现在从给定的起点出发开始到处乱走,最多可以往左走\(l\)次,往右走\(r\)次.求可能到达的点数. \(Sol\) 如果只限 ...

  5. 1024 科学计数法 (20 分)C与Java

    科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [±][1-9].[0-9]+E[±][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指数部 ...

  6. 解决 Table ‘performance_schema.session_variables’ doesn’t exist 问题

    performance_schema在mysql5.5以上就有自带 performance_schema(安装数据库时自带的)如果装数据库或者使用数据时不小心删除了,就会出现Table‘perform ...

  7. Quartz 和 springboot schedule中的cron表达式关于星期(周几)的不同表示

    一.Quartz中cron 表达式分析: quartz 官方源码(org.quartz.CronExpression)解释: Cron expressions are comprised of 6 r ...

  8. Java类成员之内部类

    内部类含义: 在Java中允许一个类的定义位于另一个类的内部,前者称为内部类,后者称为外部类. Inner class 一般用在定义它的类或语句块之内,在外部引用它时必须给出完整的名称. Inner ...

  9. 巧用位运算规律 Flags

    找规律 (1 ) &1 =1 (1 ) &2 =0 (1 ) &3 =1 (1 ) &4 =0 (1 ) &5 =1 (1 ) &6 =0 (1 ) & ...

  10. 6、使用基元类型而不要使用 FCL 类型

    基元类型: int string object uint long ulong 等 ; FCL (Framework Class Library ) System.Int32 等. 一些定义在一些语言 ...