头文件中的错误 - 构建 AVR PROJECT

问题描述

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

这是构建日志:

-------------- 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 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_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 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 '=',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))

解决方法

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

,

Something in the code prior to including adc.h I would presume. Especially since the later errors such as adc.h:22: error: expected identifier or '(' before 'extern' do not even reference stdint.h or any standard header - just your eco.c code. Looks like whatever you are doing wrong it is a habit or duplicated across your code. You need to show the code eco.c up to line 16 at least and eco.h up to line 29. You have similar issues elsewhere,but I am willing to bet it is the same error in each case. 这个答案来自@Clifford

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...