c - 头文件中的错误 - 构建 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))
解决方案
我不知不觉地在代码的开头包含了三个星号,并将这种格式复制到所有其他 .h 文件中,这就是我收到此错误的原因。谢谢你们
推荐阅读
- c# - 多个文本框输入和多个文本框通过数组输出
- ios - Flutter 在目标 Runner 上自动分配版本为 9.0 的平台 iOS,因为没有指定平台
- javascript - Safari preventDefault() 不适用于 AudioContext
- linux - Ansible grep 多个文件,然后将输出发送到邮件(使用了错误的库存)-已解决
- python - 如何在不使用类名的情况下从静态方法调用静态方法
- excel - VBA代码没有在excel中运行大量数据
- javascript - 重置下拉选择后重置列表
- python - 重新索引数据透视表以添加缺失的日期和时间
- windows - Windows Power Shell 无法识别任何内容
- javascript - ''member'' 的另一台服务器的缓存