野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11999|回复: 2

想请问一下,包含头文件的顺序问题

[复制链接]
发表于 2019-1-30 13:33:06 | 显示全部楼层 |阅读模式
各位学长,最近在学习systick定时器,按照视频输入代码的时候,在bsp_systick.h文件中包含了"stm32f10x.h"和"core_cm3.h"两个头文件,这时遇到了问题:当代码顺序为include"stm32f10x.h"在先,include"core_cm3.h"在后时,代码编译没问题,但是如果改成include"core_cm3.h"在先,include"stm32f10x.h"在后,则代码报错
请问这是什么情况,在编写代码的时候,包含头文件的顺序也是有影响的吗?
这是代码截图:
捕获.PNG

下边是编译器报错的具体内容:
Build target 'Led'
compiling bsp_systick.c...
..\..\Libraries\CMSIS\core_cm3.h(1502): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1515): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1529): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1542): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1555): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1569): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1586): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
..\..\Libraries\CMSIS\core_cm3.h(1609): error:  #20: identifier "IRQn_Type" is undefined
  static __INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
..\..\Libraries\CMSIS\core_cm3.h(1699): error:  #20: identifier "SysTick_IRQn" is undefined
    NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1);  /* set Priority for Cortex-M0 System Interrupts */
..\..\User\systick\bsp_systick.h(10): warning:  #1-D: last line of file ends without a newline
  #endif
..\..\User\systick\bsp_systick.c: 1 warning, 9 errors
"..\..\Output\流水灯.axf" - 9 Error(s), 1 Warning(s).
Target not created.
Build Time Elapsed:  00:00:01


回复

使用道具 举报

发表于 2019-2-12 08:58:15 | 显示全部楼层
有影响,如果a文件用了b文件的内容,就要先包含a文件
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-2-25 15:00:14 | 显示全部楼层
flyleaf 发表于 2019-2-12 08:58
有影响,如果a文件用了b文件的内容,就要先包含a文件

哦哦这是说即使在同一个文件内也要有顺序的吗?
回复 支持 反对

使用道具 举报

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

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-9-28 23:50 , Processed in 0.032994 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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