..\HARDWARE\USART3\usart3.h(21): error: #147: declaration is incompatible with "uint8_t USART2_RX_BUF[512]" (declared at line 12 of "..\SYSTEM\usart\usart.h") extern u8 USART2_RX_BUF[
时间: 2023-06-19 08:07:49 浏览: 157
这个错误是因为你在usart3.h中定义了一个名为USART2_RX_BUF的变量,但是在usart.h中也已经定义了一个同名的变量,并且它们的类型不一致,导致冲突。
解决这个错误的方法是修改usart3.h中的变量名,或者使用usart.h中定义的同名变量。如果你确定需要在usart3.h中定义一个新的变量,那么应该修改变量名以避免与其他文件中的变量冲突。
相关问题
compiling usart.c... ..\SYSTEM\usart\usart.c(148): error: #79: expected a type specifier USART_ClearITPendingBit(USART1, USART_IT_RXNE); ..\SYSTEM\usart\usart.c(148): error: #79: expected a type specifier USART_ClearITPendingBit(USART1, USART_IT_RXNE); ..\SYSTEM\usart\usart.c(148): warning: #77-D: this declaration has no storage class or type specifier USART_ClearITPendingBit(USART1, USART_IT_RXNE); ..\SYSTEM\usart\usart.c(148): error: #147: declaration is incompatible with "void USART_ClearITPendingBit(USART_TypeDef *, uint16_t)" (declared at line 393 of "..\STM32F10x_FWLib\inc\stm32f10x_usart.h") USART_ClearITPendingBit(USART1, USART_IT_RXNE); ..\SYSTEM\usart\usart.c(149): error: #169: expected a declaration } ..\SYSTEM\usart\usart.c(152): warning: At end of source: #12-D: parsing restarts here after previous syntax error ..\SYSTEM\usart\usart.c: 2 warnings, 4 errors "..\SYSTEM\usart\usart.c" - 4 Error(s), 2 Warning(s).
根据你提供的错误信息,编译usart.c时出现了一些问题。其中,第一个错误是在第148行,缺少了类型说明符。第二个错误也是在第148行,同样缺少了类型说明符。第三个错误是在第148行,这个声明缺少了存储类或类型说明符。第四个错误是在第148行,这个声明与在"..\STM32F10x_FWLib\inc\stm32f10x_usart.h"文件的第393行声明的 "void USART_ClearITPendingBit(USART_TypeDef *, uint16_t)" 不兼容。第五个错误是在第149行,缺少了一个声明。最后一个警告是在第152行,源码结束后重新开始解析。
根据这些信息,你需要检查usart.c文件的第148行和149行的代码,并确保声明的类型和参数与之前的声明匹配。此外,还要确保代码的结构正确,没有语法错误。
main.c(4): error: #147-D: declaration is incompatible with "void GPIO_Init(GPIO_TypeDef *, GPIO_InitTypeDef *)" (declared at line 351 of "..\STM32F10x_FWLib\inc\stm32f10x_gpio.h") void GPIO_Init(void); main.c(10): error: #268: declaration may not appear after executable statement in block uint8_t i = 0; main.c(10): error: #67: expected a "}" uint8_t i = 0; main.c(11): error: #147: declaration is incompatible with "void USART1_Init(void)" (declared at line 3) USART1_Init(); main.c(12): error: #169: expected a declaration while(1) { //???????请给出具体措施以解决这些问题
这些错误信息来自编译器,主要分为三类:
1. declaration is incompatible:在 main.c 文件中,函数的声明与在 stm32f10x_gpio.h 和其他头文件中定义的函数声明不兼容。需要检查函数的参数类型、返回值类型等是否与定义一致。
2. declaration may not appear after executable statement in block:在 main.c 文件中,变量声明放在了可执行语句之后。需要将变量声明放在可执行语句之前。
3. expected a declaration:在 main.c 文件中,缺少声明语句。需要增加相应的声明语句。
针对具体的错误信息,可以采取以下措施:
1. 在 main.c 文件中,将 GPIO_Init 函数的声明修改为与 stm32f10x_gpio.h 文件中定义的函数声明一致。
2. 将变量 i 的声明放在可执行语句之前。
3. 在 main.c 文件中,增加 USART1_Init 函数的声明语句。