OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 39090|回复: 10

为什么每次我编译程序都会遇到这种问题

[复制链接]

6

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
74
金钱
74
注册时间
2014-4-26
在线时间
1 小时
发表于 2014-5-25 22:59:03 | 显示全部楼层 |阅读模式
5金钱
原子哥,看下为什么我编译老是会出现在这种问题,而且网上的改错方案很多,但是没有一个是可行的。


Build target 'Target 1'
compiling test.c...
..\USMART\usmart_str.h(24): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of "C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h")
compiling sys.c...
..\SYSTEM\sys\sys.c(76): error:  #136: struct "<unnamed>" has no field "IPR"
..\SYSTEM\sys\sys.c(127): error:  #20: identifier "NVIC_VectTab_FLASH" is undefined
compiling usart.c...
..\SYSTEM\usart\usart.c(123): error:  #20: identifier "USART1_IRQChannel" is undefined
compiling led.c...
..\HARDWARE\LED\led.c(1): error:  #5: cannot open source input file "stm32f10x_lib.h": No such file or directory
compiling key.c...
..\HARDWARE\KEY\key.c(1): error:  #5: cannot open source input file "stm32f10x_lib.h": No such file or directory
compiling exti.c...
..\HARDWARE\EXTI\exti.c(64): error:  #20: identifier "EXTI0_IRQChannel" is undefined
..\HARDWARE\EXTI\exti.c(65): error:  #20: identifier "EXTI15_10_IRQChannel" is undefined
compiling wdg.c...
..\HARDWARE\WDG\wdg.c(52): error:  #20: identifier "WWDG_IRQChannel" is undefined
compiling timer.c...
..\USMART\usmart_str.h(24): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of "C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h")
..\HARDWARE\TIMER\timer.c(41): error:  #20: identifier "TIM3_IRQChannel" is undefined
..\HARDWARE\TIMER\timer.c(95): error:  #20: identifier "TIM2_IRQChannel" is undefined
compiling usmart.c...
C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h(503): error:  #256: invalid redeclaration of type name "u32" (declared at line 24 of "..\USMART\usmart_str.h")
compiling usmart_config.c...
C:\Keil\ARM\Inc\ST\STM32F10x\stm32f10x.h(503): error:  #256: invalid redeclaration of type name "u32" (declared at line 24 of "..\USMART\usmart_str.h")
".\TEST.axf" - 14 Errors, 0 Warning(s).
Target not created
先后试过下面两种解决途径,但是都没有什么用
1.修改define里面的内容


2.include多个路径



最佳答案

查看完整内容[请看2#楼]

 用3.5的库,所有的USART1_IRQChannel,全部变成:USART1_IRQn。 详见此贴:http://www.openedv.com/posts/list/29355.htm
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165536
金钱
165536
注册时间
2010-12-1
在线时间
2117 小时
发表于 2014-5-25 22:59:04 | 显示全部楼层
 用3.5的库,所有的USART1_IRQChannel,全部变成:USART1_IRQn。
详见此贴:http://www.openedv.com/posts/list/29355.htm
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165536
金钱
165536
注册时间
2010-12-1
在线时间
2117 小时
发表于 2014-5-25 22:59:04 | 显示全部楼层
 在usmart_str.h,去掉我们定义的u32之类的数据。
所有的XXX_IRQChannel,都需要改为:XXX_IRQn
NVIC_VectTab_FLASH之类的定义,直接去掉。或者用其他的替换。或者自己定义。
stm32f10x_map.h,不需要再包含了。
IPR,全部要换成IP。

SYSTEM文件夹,请用以下最新的(使用stm32f10x.h了)

SYSTEM.zip

12.55 KB, 下载次数: 2526

我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复

使用道具 举报

6

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
74
金钱
74
注册时间
2014-4-26
在线时间
1 小时
 楼主| 发表于 2014-5-26 10:53:11 | 显示全部楼层
先谢谢原子哥,这么专业,这么快速的回答是在令我感激不尽,在其他的论坛上面发帖子问问题是在是看运气啊。觉得原子哥有必要做个整理,将论坛上关于两个库之间移植出现的问题搞在一起,来一个根本的帖子,这样子可能原子哥回答问题不会那么多。
回复

使用道具 举报

6

主题

25

帖子

0

精华

初级会员

Rank: 2

积分
74
金钱
74
注册时间
2014-4-26
在线时间
1 小时
 楼主| 发表于 2014-5-26 11:15:48 | 显示全部楼层
还是不行啊,原子哥,我已经这样子做了,可是错误还是一大堆,见截图。



Build target 'Target 1'
compiling test.c...
..\USMART\usmart_str.h(24): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of "..\SYSTEM\sys\stm32f10x.h")
compiling sys.c...
..\SYSTEM\sys\sys.c(76): error:  #136: struct "<unnamed>" has no field "IPR"
..\SYSTEM\sys\sys.c(127): error:  #20: identifier "NVIC_VectTab_FLASH" is undefined
compiling usart.c...
..\SYSTEM\usart\usart.c(123): error:  #20: identifier "USART1_IRQChannel" is undefined
compiling led.c...
..\SYSTEM\sys\stm32f10x_lib.h(22): error:  #5: cannot open source input file "stm32f10x_map.h": No such file or directory
compiling key.c...
..\SYSTEM\sys\stm32f10x_lib.h(22): error:  #5: cannot open source input file "stm32f10x_map.h": No such file or directory
compiling exti.c...
..\HARDWARE\EXTI\exti.c(64): error:  #20: identifier "EXTI0_IRQChannel" is undefined
..\HARDWARE\EXTI\exti.c(65): error:  #20: identifier "EXTI15_10_IRQChannel" is undefined
compiling wdg.c...
..\HARDWARE\WDG\wdg.c(52): error:  #20: identifier "WWDG_IRQChannel" is undefined
compiling timer.c...
..\USMART\usmart_str.h(24): error:  #256: invalid redeclaration of type name "u32" (declared at line 503 of "..\SYSTEM\sys\stm32f10x.h")
..\HARDWARE\TIMER\timer.c(41): error:  #20: identifier "TIM3_IRQChannel" is undefined
..\HARDWARE\TIMER\timer.c(95): error:  #20: identifier "TIM2_IRQChannel" is undefined
compiling usmart.c...
..\SYSTEM\sys\stm32f10x.h(503): error:  #256: invalid redeclaration of type name "u32" (declared at line 24 of "..\USMART\usmart_str.h")
compiling usmart_config.c...
..\SYSTEM\sys\stm32f10x.h(503): error:  #256: invalid redeclaration of type name "u32" (declared at line 24 of "..\USMART\usmart_str.h")
".\TEST.axf" - 14 Errors, 0 Warning(s).
Target not created
回复

使用道具 举报

5

主题

27

帖子

0

精华

初级会员

Rank: 2

积分
85
金钱
85
注册时间
2015-4-6
在线时间
4 小时
发表于 2015-4-24 10:32:49 | 显示全部楼层
..\HARDWARE\USART3\USART3.c(72): error:  #77-D: this declaration has no storage class or type specifier
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;             //PB.10
..\HARDWARE\USART3\USART3.c(72): error:  #147: declaration is incompatible with "GPIO_InitTypeDef GPIO_InitStructure" (declared at line 18)
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;             //PB.10
..\HARDWARE\USART3\USART3.c(72): error:  #65: expected a ";"
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;             //PB.10
..\HARDWARE\USART3\USART3.c(73): error:  #77-D: this declaration has no storage class or type specifier
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
..\HARDWARE\USART3\USART3.c(73): error:  #147: declaration is incompatible with "GPIO_InitTypeDef GPIO_InitStructure" (declared at line 72)
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
..\HARDWARE\USART3\USART3.c(73): error:  #65: expected a ";"
      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
..\HARDWARE\USART3\USART3.c(74): error:  #77-D: this declaration has no storage class or type specifier
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;           //复用推挽输出
..\HARDWARE\USART3\USART3.c(74): error:  #147: declaration is incompatible with "GPIO_InitTypeDef GPIO_InitStructure" (declared at line 73)
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;           //复用推挽输出
..\HARDWARE\USART3\USART3.c(74): error:  #65: expected a ";"
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;           //复用推挽输出
..\HARDWARE\USART3\USART3.c(75): error:  #79: expected a type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);                   //初始化PB10
..\HARDWARE\USART3\USART3.c(75): error:  #79: expected a type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);                   //初始化PB10
..\HARDWARE\USART3\USART3.c(75): warning:  #77-D: this declaration has no storage class or type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);                   //初始化PB10
..\HARDWARE\USART3\USART3.c(75): error:  #147: declaration is incompatible with "void GPIO_Init(GPIO_TypeDef *, GPIO_InitTypeDef *)" (declared at line 351 of "..\STM32F10x_FWLib\inc\stm32f10x_gpio.h")
      GPIO_Init(GPIOB, &GPIO_InitStructure);                   //初始化PB10
..\HARDWARE\USART3\USART3.c(78): error:  #77-D: this declaration has no storage class or type specifier
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
..\HARDWARE\USART3\USART3.c(78): error:  #147: declaration is incompatible with "GPIO_InitTypeDef GPIO_InitStructure" (declared at line 74)
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
..\HARDWARE\USART3\USART3.c(78): error:  #65: expected a ";"
      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
..\HARDWARE\USART3\USART3.c(79): error:  #77-D: this declaration has no storage class or type specifier
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入
..\HARDWARE\USART3\USART3.c(79): error:  #147: declaration is incompatible with "GPIO_InitTypeDef GPIO_InitStructure" (declared at line 78)
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入
..\HARDWARE\USART3\USART3.c(79): error:  #65: expected a ";"
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;//浮空输入
..\HARDWARE\USART3\USART3.c(80): error:  #79: expected a type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);               //初始化PB11
..\HARDWARE\USART3\USART3.c(80): error:  #79: expected a type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);               //初始化PB11
..\HARDWARE\USART3\USART3.c(80): warning:  #77-D: this declaration has no storage class or type specifier
      GPIO_Init(GPIOB, &GPIO_InitStructure);               //初始化PB11
..\HARDWARE\USART3\USART3.c(180): error:  #79: expected a type specifier
      RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 , ENABLE); 
..\HARDWARE\USART3\USART3.c(180): error:  #757: constant "ENABLE" is not a type name
      RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 , ENABLE); 
..\HARDWARE\USART3\USART3.c(180): warning:  #77-D: this declaration has no storage class or type specifier
      RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 , ENABLE); 
..\HARDWARE\USART3\USART3.c(180): error:  #147: declaration is incompatible with "void RCC_APB1PeriphClockCmd(uint32_t, FunctionalState)" (declared at line 694 of "..\STM32F10x_FWLib\inc\stm32f10x_rcc.h")
      RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 , ENABLE); 
..\HARDWARE\USART3\USART3.c(183): error:  #79: expected a type specifier
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
..\HARDWARE\USART3\USART3.c(183): error:  #757: constant "ENABLE" is not a type name
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
..\HARDWARE\USART3\USART3.c(183): warning:  #77-D: this declaration has no storage class or type specifier
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
..\HARDWARE\USART3\USART3.c(183): error:  #147: declaration is incompatible with "void RCC_AHBPeriphClockCmd(uint32_t, FunctionalState)" (declared at line 692 of "..\STM32F10x_FWLib\inc\stm32f10x_rcc.h")
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
..\HARDWARE\USART3\USART3.c(185): error:  #77-D: this declaration has no storage class or type specifier
        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel2_IRQn;
..\HARDWARE\USART3\USART3.c(185): error:  #147: declaration is incompatible with "NVIC_InitTypeDef NVIC_InitStructure" (declared at line 17)
        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel2_IRQn;
..\HARDWARE\USART3\USART3.c(185): error:  #65: expected a ";"
        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel2_IRQn;
..\HARDWARE\USART3\USART3.c(186): error:  #77-D: this declaration has no storage class or type specifier
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
..\HARDWARE\USART3\USART3.c: 4 warnings, 30 errors
"..\OBJ\GPS.axf" - 30 Error(s), 4 Warning(s).

这个该怎么解决啊,求大神帮忙?
回复

使用道具 举报

0

主题

1

帖子

0

精华

新手入门

积分
2
金钱
2
注册时间
2016-2-4
在线时间
0 小时
发表于 2016-2-4 11:23:27 | 显示全部楼层
原来是这样,哈哈,3Q
回复

使用道具 举报

10

主题

146

帖子

0

精华

高级会员

Rank: 4

积分
764
金钱
764
注册时间
2015-12-19
在线时间
99 小时
发表于 2016-2-13 19:15:08 | 显示全部楼层
正点原子 发表于 2014-5-25 22:59
&nbsp;用3.5的库,所有的USART1_IRQChannel,全部变成:USART1_IRQn。
详见此贴:http://www.openedv.com/ ...

之前也碰到过类似的问题  今天看到回复  正点的解答   很到位  
回复

使用道具 举报

天涯hah 该用户已被删除
发表于 2016-12-25 21:49:54 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

天涯hah 该用户已被删除
发表于 2016-12-25 22:32:54 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

5

主题

57

帖子

0

精华

初级会员

Rank: 2

积分
146
金钱
146
注册时间
2018-3-11
在线时间
20 小时
发表于 2018-4-4 09:53:24 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-9 02:06

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表