打印

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

[复制链接]
2623|9
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
keer_zu|  楼主 | 2007-3-25 10:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
命令编译后:
> "make.exe" all

-------- begin --------
avr-gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling C: hello.c
avr-gcc -c -mmcu=atmega162 -I. -gstabs -DF_CPU=7372800UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=obj/hello.lst  -std=gnu99 -Wundef -MD -MP -MF .dep/hello.o.d hello.c -o obj/hello.o 
In file included from hello.c:5:
d:/WinAVR/avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."
In file included from hello.c:6:
d:/WinAVR/avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
hello.c: In function `main':
hello.c:92: warning: array subscript has type `char'
hello.c:95: warning: array subscript has type `char'
hello.c:101: warning: array subscript has type `char'
hello.c:104: warning: array subscript has type `char'
hello.c:106: warning: array subscript has type `char'
hello.c: In function `__vector_15':
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'
hello.c: In function `Get_pulse_num':
hello.c:220: warning: array subscript has type `char'

象这样的警告是怎么回事?
特别是以下:
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'
谢谢指教!帮帮忙吧!

相关帖子

沙发
keer_zu|  楼主 | 2007-3-25 16:25 | 只看该作者

出现问题的代码:

告警:

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);
.............

使用特权

评论回复
板凳
ayb_ice| | 2007-3-26 08:02 | 只看该作者

随便说说

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}};
//
  long long啥东东

使用特权

评论回复
地板
keer_zu|  楼主 | 2007-3-26 08:24 | 只看该作者

long long

long long 
是64位数据类型,好多编译器支持.

使用特权

评论回复
5
ayb_ice| | 2007-3-26 08:27 | 只看该作者

随便说说

  是不是char类型要放于前面...

使用特权

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

你是说在结构体里面吗?

使用特权

评论回复
7
ayb_ice| | 2007-3-26 08:59 | 只看该作者

随便说说

  对,试一下...

使用特权

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

我把LONG LONG 型换成CHAR还是不行

看来问题不是这里.

使用特权

评论回复
9
keer_zu|  楼主 | 2007-3-26 09:18 | 只看该作者

我把结构体换成三个数组还是不行,老样子

使用特权

评论回复
10
ayb_ice| | 2007-3-26 09:35 | 只看该作者

随便说说

你先定义一结构体,再定义一结构体型变量试试...

使用特权

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

本版积分规则

1349

主题

12424

帖子

53

粉丝