告警:
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); ............. |