stm32:error: #268: declaration may not appear after executable statement in block
2017-08-10 16:24
519 查看
今天写中断函数时报错:
error: #268: declaration may not appear after executable statement in block
谷歌翻译直译过来就是
声明可能不会出现在块中的可执行语句之后
![](https://img-blog.csdn.net/20170810161730137?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGQzMjAw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
其实语句没有什么问题,但是
EXTI_InitTypeDef EXTI_Struct;
这句话的位置有错误,应该放在大括号后面
![](https://img-blog.csdn.net/20170810161908073?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvQnVpbGQzMjAw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
32的库中,结构体大部分都加的typedef,意味着要重新声明,可以理解为EXTI_InitTypeDef可以重新定义变量,然后通过 “.” 访问结构体中的内容。类似于
C语言规定变量声明必须在函数开头,也就是大括号之后。
EXTI_InitTypeDef EXTI_Struct; 这句话相当于在声明变量,所以放在函数中会报错。
MDK5默认的还是C89标准,限定了声明变量的位置。在C99标准中则没有此限制,如果想开启C99标准则可通过打开魔术棒中的C/C++面板,勾选“C99Mode”。
error: #268: declaration may not appear after executable statement in block
谷歌翻译直译过来就是
声明可能不会出现在块中的可执行语句之后
其实语句没有什么问题,但是
EXTI_InitTypeDef EXTI_Struct;
这句话的位置有错误,应该放在大括号后面
32的库中,结构体大部分都加的typedef,意味着要重新声明,可以理解为EXTI_InitTypeDef可以重新定义变量,然后通过 “.” 访问结构体中的内容。类似于
typedef unsigned char uchar ;uchar= ** ;
C语言规定变量声明必须在函数开头,也就是大括号之后。
EXTI_InitTypeDef EXTI_Struct; 这句话相当于在声明变量,所以放在函数中会报错。
MDK5默认的还是C89标准,限定了声明变量的位置。在C99标准中则没有此限制,如果想开启C99标准则可通过打开魔术棒中的C/C++面板,勾选“C99Mode”。
相关文章推荐
- keil中变量声明问题及error: #268: declaration may not appear after executable statement in block
- error: declaration may not appear after executable statement in block
- 【complier】error: #268: declaration may not appear after executable statement in block
- #268: declaration may not appear after executable statement in block 另类错误原因
- #268: declaration may not appear after executable statement in block
- error: declaration may not appear after executable statement in block
- error: #268: declaration may not appear after executabl statement in block
- KeilMDK 编译报错:error: #268: declaration may not appear after executable statement in block
- error: declaration may not appear after executable statement in block
- error: declaration may not appear after executable statement in block
- 使用Keil-STM32,cmsis_os.c 出现 error: #268: declaration may not appear after executable....
- declaration may not appear after executable statement in block
- declaration may not appear after executable statement in block
- declaration may not appear after executable statement in block
- declaration may not appear after executable statement in block
- 搞定error: #268: declaration may not appear after executable statement
- SQL Error:An aggregate may not appear in the set list of an UPDATE statement.
- ARMCC: Error #268: declaration may not appear after executable state
- Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in
- "new types may not be defined in a return type" error