打印
[AVR单片机]

请教WINAVR编译器问题,谢谢!

[复制链接]
1662|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);
.............

使用特权

评论回复
5
keer_zu|  楼主 | 2007-3-26 08:28 | 只看该作者

还请qjy_dali和各位指教

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1344

主题

12408

帖子

53

粉丝