在构建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 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))发布于 2021-03-10 10:49:41
我在不知情的情况下在代码开头添加了三个星号,并将此格式复制到所有其他.h文件中,这就是我收到此错误的原因。谢谢大家
发布于 2021-03-10 11:08:19
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
https://stackoverflow.com/questions/66516570
复制相似问题