首页 > 解决方案 > 头文件中的错误 - 构建 AVR PROJECT 时代码块中的 stdint.h

问题描述

在构建 AVR 项目时,我在 stdint.h 文件中遇到错误。在这里,我尝试在汽车中模拟不同的驾驶模式,例如舒适、环保和运动模式。我从没想过我会得到这样的错误,这是因为一些配置错误,有人可以帮助我吗?我已在此处附加实际代码驾驶模式

这是构建日志:

-------------- Clean: Debug in driving modes (compiler: GNU GCC Compiler for AVR)---------------

Cleaned "driving modes - Debug"

-------------- Build: Debug in driving modes (compiler: GNU GCC Compiler for AVR)---------------

avr-gcc.exe -Wall -mmcu=atmega328p -DF_CPU=16000000UL -g -IC:\WinAVR\avr\include -c adc.c -o obj\Debug\adc.o
avr-gcc.exe -Wall -mmcu=atmega328p -DF_CPU=16000000UL -g -IC:\WinAVR\avr\include -c comfort.c -o obj\Debug\comfort.o
avr-gcc.exe -Wall -mmcu=atmega328p -DF_CPU=16000000UL -g -IC:\WinAVR\avr\include -c eco.c -o obj\Debug\eco.o
avr-gcc.exe -Wall -mmcu=atmega328p -DF_CPU=16000000UL -g -IC:\WinAVR\avr\include -c fuse.c -o obj\Debug\fuse.o
In file included from c:/winavr-20100110/lib/gcc/../../avr/include/inttypes.h:37,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/sfr_defs.h:126,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/io.h:99,
                 from adc.h:16,
                 from adc.c:14:
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:121: error: expected identifier or '(' before 'typedef'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:159: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_least8_t'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:213: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_fast8_t'
In file included from c:/winavr-20100110/lib/gcc/../../avr/include/inttypes.h:37,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/sfr_defs.h:126,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/io.h:99,
                 from GPIO.h:16,
                 from comfort.c:13:
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:121: error: expected identifier or '(' before 'typedef'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:159: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_least8_t'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:213: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_fast8_t'
In file included from GPIO.h:17,
                 from comfort.c:13:
c:/winavr-20100110/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
In file included from comfort.c:14:
adc.h:22: error: expected identifier or '(' before 'extern'
In file included from comfort.c:15:
pwm.h:22: error: expected identifier or '(' before 'extern'
In file included from comfort.c:16:
comfort.h:29: error: expected identifier or '(' before 'extern'
comfort.c: In function 'comfort':
comfort.c:32: error: 'ADC_VALUE' undeclared (first use in this function)
comfort.c:32: error: (Each undeclared identifier is reported only once
comfort.c:32: error: for each function it appears in.)
Process terminated with status 1 (0 minute(s), 0 second(s))
 
In file included from adc.h:17,
                 from adc.c:14:
c:/winavr-20100110/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
adc.c: In function 'adc_config':
adc.c:30: warning: implicit declaration of function 'sei'
Process terminated with status 1 (0 minute(s), 0 second(s))
 
In file included from c:/winavr-20100110/lib/gcc/../../avr/include/inttypes.h:37,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/sfr_defs.h:126,
                 from c:/winavr-20100110/lib/gcc/../../avr/include/avr/io.h:99,
                 from GPIO.h:16,
                 from eco.c:13:
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:121: error: expected identifier or '(' before 'typedef'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:159: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_least8_t'
c:/winavr-20100110/lib/gcc/../../avr/include/stdint.h:213: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'int_fast8_t'
In file included from GPIO.h:17,
                 from eco.c:13:
c:/winavr-20100110/lib/gcc/../../avr/include/util/delay.h:90:3: warning: #warning "Compiler optimizations disabled; functions from <util/delay.h> won't work as designed"
In file included from eco.c:14:
adc.h:22: error: expected identifier or '(' before 'extern'
In file included from eco.c:15:
pwm.h:22: error: expected identifier or '(' before 'extern'
In file included from eco.c:16:
eco.h:29: error: expected identifier or '(' before 'void'
eco.c: In function 'eco':
eco.c:32: error: 'ADC_VALUE' undeclared (first use in this function)
eco.c:32: error: (Each undeclared identifier is reported only once
eco.c:32: error: for each function it appears in.)
Process terminated with status 1 (0 minute(s), 0 second(s))
 
Process terminated with status 0 (0 minute(s), 0 second(s))
21 error(s), 4 warning(s) (0 minute(s), 0 second(s))

标签: cembeddedcodeblocksavravr-gcc

解决方案


我不知不觉地在代码的开头包含了三个星号,并将这种格式复制到所有其他 .h 文件中,这就是我收到此错误的原因。谢谢你们


推荐阅读