1、ICC 错误集锦 看懂 ICC AVR 的报错新手用 ICC 编程的时候,经常会出现一些错误,现在将常见的错误报告整理如下。这里的一些错误是我为了展示而故意制造的,欢迎你提供你遇到的错误。排名不分先后:一、正常编译通过 CODE:C:iccbinimakew -f main.makiccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED 应用霓虹灯main.ciccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -
2、dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 main.lk -lcatmegaDevice 1% full.Done.这是我们最想看到的了,万事大吉。二、工程中未加入.C 文件CODE:C:iccbinimakew -f main.makiccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom
3、:1.512 -fihx_coff -S2 main.lk -lcatmegaunknown file type main.lk, passed to linker!ERROR unknown file type main.lkC:iccbinimakew.exe: Error code 1Done: there are error(s). Exit code: 1解决办法:将你的程序加入工程中,可以右键程序区ADD to project三、程序没有后缀名,或者后缀名不正确。CODE:C:iccbinimakew -f main.makC:iccbinimakew.exe: main is u
4、p to dateDone.这是一个很难理解的错误,它是由工程中的程序文件没有后缀名造成的。解决办法:将原有文件移出工程,将文件的后缀名改为.C,然后再加入工程中。四、没有 main 函数CODE:C:iccbinimakew -f main.makiccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED 应用霓虹灯main.ciccavr -o main -LC:icclib -g -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -
5、bdata:0x60.0x45f -dhwstk_size:16 -beeprom:1.512 -fihx_coff -S2 main.lk -lcatmega!ERROR file crtatmega.o: undefined symbol _mainC:iccbinimakew.exe: Error code 1Done: there are error(s). Exit code: 1解决办法,编写程序主函数 MAIN。五、没有选择目标芯片出现如下错误:CODE:C:iccbinimakew -f main.makiccavr -c -IC:iccinclude -e -l -g -Wa
6、-W D:桌面实验教程LED 应用霓虹灯main.ciccavr -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 valueC
7、:iccbinimakew.exe: Error code 1Done: there are error(s). Exit code: 1解决办法:projectOptionstargetdevice configuration 选择合适的芯片。六、缺少分号CODE:C:iccbinimakew -f main.makiccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED 应用霓虹灯main.c!E D:桌面实验教程LED 应用霓虹灯main.c(52): unrecognized sta
8、tement!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 1C:iccbinimakew.exe: main.o removed.Done: there are error(s). Exit code: 1上面的报告说明了第 52 行缺少一个分号,预期分号的地方出现了“”。解决方法,在 52 行末尾添加分号
9、。类似的有:缺少的报错 CODE:C:iccbinimakew -f main.makiccavr -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 wit
10、hout 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 1C:iccbinimakew.exe: main.o removed.Done: there are error(s). Exit code: 1七:变量没有定义CODE:C:iccbinimake
11、w -f main.makiccavr -c -IC:iccinclude -e -DATMEGA -DATMega16 -l -g -Mavr_enhanced D:桌面实验教程LED 应用霓虹灯main.c!E D:桌面实验教程LED 应用霓虹灯main.c(48): undeclared identifier iC:iccbinimakew.exe: Error code 1C:iccbinimakew.exe: main.o removed.Done: there are error(s). Exit code: 1解决办法:在程序开始前添加变量定义,比如 unsigned char i;注意,定义变量要在函数的最前面进行,及在进行计算操作之前定义所有变量。