[AVR单片机] 请教WINAVR编译器问题,谢谢!

[复制链接]
2789|4
 楼主| keer_zu 发表于 2007-3-25 10:22 | 显示全部楼层 |阅读模式
象这样的警告是怎么回事?
特别是以下:
hello.c:181: warning: array subscript has type `char'
hello.c:185: warning: array subscript has type `char'
hello.c:204: warning: array subscript has type `char'
hello.c:208: warning: array subscript has type `char'
谢谢指教!帮我看看吧!
qjy_dali 发表于 2007-3-25 13:07 | 显示全部楼层

把出警告的那段代码贴出来看看

 楼主| keer_zu 发表于 2007-3-25 15:55 | 显示全部楼层

谢谢你 这是:

以下是我定义的结构体:
struct Port_count
{
    long long pul_count;           //端口脉冲计数器
    char Lhold_count;              //端口高电平保持计数器
    char Hhold_count;              //端口堤电平保持计数器
}port_c[16] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
//

以下是部分告警的代码行:
....................
.....................
..............
port_c.Hhold_count += 1;
..................
..................
if(port_c.Hhold_count >= 3)
.....................
.....................
.....................
num = ascii((char)(port_c.pul_count) % 10);


请指点
 楼主| keer_zu 发表于 2007-3-25 16:26 | 显示全部楼层

我再描述一遍,请qjy_dali和给位指教:

告警:

hello.c: In function `main':
hello.c:94: warning: array subscript has type `char'
hello.c:97: warning: array subscript has type `char'
hello.c:105: warning: array subscript has type `char'
hello.c:108: warning: array subscript has type `char'
hello.c:110: warning: array subscript has type `char'
hello.c: In function `__vector_15':
hello.c:203: warning: array subscript has type `char'
hello.c:207: warning: array subscript has type `char'
hello.c:228: warning: array subscript has type `char'
hello.c:232: warning: array subscript has type `char'
hello.c: In function `Get_pulse_num':
hello.c:244: warning: array subscript has type `char'
hello.c: In function `display_pul_num':
hello.c:287: warning: array subscript has type `char'
hello.c:289: warning: array subscript has type `char'
hello.c:291: warning: array subscript has type `char'


我定义的结构体:

//脉冲记录使用的全局变量:
struct Port_count
{
    long long pul_count;           //端口脉冲计数器
    char Lhold_count;              //端口高电平保持计数器
    char Hhold_count;              //端口堤电平保持计数器
}port_c[16] = {{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0}};
//


出现问题的代码:
.......
if(port_c.Hhold_count >= 3)
........
                        
port_c.Hhold_count = 0;     //计数器清零

...........
                    
if(port_c.Lhold_count >= 3)

..........
                        
port_c.pul_count += 1;        //脉冲计数器加一

........

port_c.Lhold_count = 0;     //计数器清零    

.......

port_c.Hhold_count += 1;        //高电平保持计数器加一

....

port_c.Hhold_count = 0;

.....

num = ascii((char)(port_c.pul_count) / 100);

......

num = ascii((((char)(port_c.pul_count) - (num - 48) * 100)) / 10);

..........

num = ascii((char)(port_c.pul_count) % 10);
.............
 楼主| keer_zu 发表于 2007-3-26 08:28 | 显示全部楼层

还请qjy_dali和各位指教

您需要登录后才可以回帖 登录 | 注册

本版积分规则

1488

主题

12949

帖子

55

粉丝
快速回复 在线客服 返回列表 返回顶部