ICC错误集锦,看懂ICC AVR的报错
新手用ICC编程的时候,经常会出现一些错误,现在将常见的错误报告整理如下。这里的一些错误是我为了展示而故意制造的,欢迎你提供你遇到的错误。排名不分先后:
本文引用地址:https://www.eepw.com.cn/article/201610/311530.htm一、正常编译通过
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED应用霓虹灯main.c
iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega
Device 1% full.
Done.
[Copy to clipboard]
这是我们最想看到的了,万事大吉。
二、工程中未加入.C文件
CODE:
C:iccbinimakew -f main.mak
iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega
unknown file type @main.lk, passed to linker
!ERROR unknown file type '@main.lk'
C:iccbinimakew.exe: Error code 1
Done: there are error(s). Exit code: 1
[Copy to clipboard]
解决办法:将你的程序加入工程中,可以右键程序区>>ADD to project
三、程序没有后缀名,或者后缀名不正确。
CODE:
C:iccbinimakew -f main.mak
C:iccbinimakew.exe: 'main' is up to date
Done.
[Copy to clipboard]
这是一个很难理解的错误,它是由工程中的程序文件没有后缀名造成的。
解决办法:将原有文件移出工程,将文件的后缀名改为.C,然后再加入工程中。
四、没有main函数
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED应用霓虹灯main.c
iccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk -lcatmega
!ERROR file 'crtatmega.o': undefined symbol '_main'
C:iccbinimakew.exe: Error code 1
Done: there are error(s). Exit code: 1
[Copy to clipboard]
解决办法,编写程序主函数MAIN。
五、没有选择目标芯片出现如下错误:
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -l -g -Wa-W D:桌面实验教程LED应用霓虹灯main.c
iccavr -o main -LC:icclib -g -Wl-W -bfunc_lit:0.0x2000 -dram_end:0x25f -bdata:0x60.0x25f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 @main.lk
!E C:icclibcrtAVR.o(41): Code address 0 already contains a value
!E C:icclibcrtAVR.o(41): Code address 0x1 already contains a value
C:iccbinimakew.exe: Error code 1
Done: there are error(s). Exit code: 1
[Copy to clipboard]
解决办法:project>>Options>>target>>device configuration 选择合适的芯片。
六、缺少分号
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED应用霓虹灯main.c
!E D:桌面实验教程LED应用霓虹灯main.c(52): unrecognized statement
!E D:桌面实验教程LED应用霓虹灯main.c(53): syntax error; found `}' expecting `;'
!E D:桌面实验教程LED应用霓虹灯main.c(53): syntax error; found `end of input' expecting `}'
C:iccbinimakew.exe: Error code 1
C:iccbinimakew.exe: 'main.o' removed.
Done: there are error(s). Exit code: 1
[Copy to clipboard]
上面的报告说明了第52行缺少一个分号,预期分号的地方出现了“}”。
解决方法,在52行末尾添加分号。
类似的有:缺少}的报错
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED应用霓虹灯main.c
!E D:桌面实验教程LED应用霓虹灯main.c(55): illegal statement termination
!E D:桌面实验教程LED应用霓虹灯main.c(55): skipping `void'
!W D:桌面实验教程LED应用霓虹灯main.c(55):[warning] calling function without prototype may cause errors
!E D:桌面实验教程LED应用霓虹灯main.c(56): syntax error; found `{' expecting `;'
!E D:桌面实验教程LED应用霓虹灯main.c(57): syntax error; found `end of input' expecting `}'
C:iccbinimakew.exe: Error code 1
C:iccbinimakew.exe: 'main.o' removed.
Done: there are error(s). Exit code: 1
[Copy to clipboard]
七:变量没有定义
CODE:
C:iccbinimakew -f main.mak
iccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED应用霓虹灯main.c
!E D:桌面实验教程LED应用霓虹灯main.c(48): undeclared identifier `i'
C:iccbinimakew.exe: Error code 1
C:iccbinimakew.exe: 'main.o' removed.
Done: there are error(s). Exit code: 1
[Copy to clipboard]
解决办法:在程序开始前添加变量定义,比如unsigned char i;注意,定义变量要在函数的最前面进行,及在进行计算操作之前定义所有变量。
欢迎你发布你遇到的错误和解决方法,或者你遇到的错误还没解决的。
八、在编译时总是不能生成COF文件,不能进行调试
解决办法:在ICCAVR编译环境中,进入Project -> Option -> Compiler中在Output format区选COFF/HEX格式
九、请指点一下:
我的程序出现下列错误提示,是不是我什么地方设置错了呀。
CODE:
D:iccbinimakew -f tex.mak
-lstudio -lfpavr
want size 346
lo 3910 hi 4096 size 187
!E (37): area 'text' not large enough
D:iccbinimakew.exe: Error code 1
Done: there are error(s). Exit code: 1
一点错误那行的时候就出来一个提示框,但没有移到某一行上去。。。。
ans1:还没有确切的解释,可能原因:应该是定义的数组过大,减小数组的数量应该可以了
ans2:这是超过编译空间了,你可以到压缩下代码,project>options>compiler,选择Enable code compression或者只有优化代码了
十:无意中又发现一个:
too many arguments to `delay_1ms'
问题原因,函数的参数太多,比如上面一个定义的是delay_1ms(void),我确用了delay_1ms(1);改为delay_1ms();就好了。
十一、!ERROR can't open file 'libiccavrlibsliccatmega-m.a'
刚才问了一下人,新建一个工程,然后把所有的C文件都导入里面,就没有的问题了,剩下一些语法错误。
十二、ICC7 的代码大小限制的问题,DEMO版超过4K不能编译。
D:PROGRA~1iccv7avrbinimakew -f mytest.mak
D:PROGRA~1iccv7avrbinimakew.exe: Couldn't open mytest GetLastError() = 5
Done: there are error(s). Exit code: 1
(斑竹,我后来发现这好像是因为ICC编译生成的某些文件有错误,把ICC生成的文件都删掉,重新建立一个project,重新选择Target,重新编译就好了)
十三、
CODE:
iccavr -o main -LD:avricclib -g -ucrtatmega.o -bfunc_lit:0x8c.0x10000 -dram_end:0x10ff -bdata:0x100.0x10ff -dhwstk_size:16 -beeprom:1.2048 -fihx_coff -S2 @main.lk D:PROTEU~1.7PROTEU~1.7JOHUmcuallCH375HFB.A -lcatmega
Device 45% full.
warning: COFF no struct tag '_CMD_PARAM' found for symbol index 1362
Done.
一个警告,搞不太清楚,以前starnewtech说过,好像是ram不够用了。
十四、重复定义 ,请在包含的头文件里面用这种格式。
#ifndef __config_H__
#define __config_H__ 1
//你的定义放这里。
#endif
评论